Browse Source

Undo queue reposition if the backend action isn't succesful

Kristian Vos 3 years ago
parent
commit
822f9c822b
1 changed files with 21 additions and 0 deletions
  1. 21 0
      frontend/src/components/Queue.vue

+ 21 - 0
frontend/src/components/Queue.vue

@@ -240,6 +240,21 @@ export default {
 				},
 				res => {
 					new Toast({ content: res.message, timeout: 4000 });
+					if (res.status !== "success") {
+						if (this.sector === "station") {
+							this.repositionSongInListStation({
+								...moved.element,
+								newIndex: moved.oldIndex,
+								oldIndex: moved.newIndex
+							});
+						} else if (this.sector === "manageStation") {
+							this.repositionSongInListManageStation({
+								...moved.element,
+								newIndex: moved.oldIndex,
+								oldIndex: moved.newIndex
+							});
+						}
+					}
 				}
 			);
 		},
@@ -261,6 +276,12 @@ export default {
 				}
 			});
 		},
+		...mapActions("modals/manageStation", {
+			repositionSongInListManageStation: "repositionSongInList"
+		}),
+		...mapActions("station", {
+			repositionSongInListStation: "repositionSongInList"
+		}),
 		...mapActions("modalVisibility", ["openModal"]),
 		...mapActions({
 			showManageStationTab: "modals/manageStation/showTab"