Browse Source

Fixed issue with Get all songs on admin pages

Kristian Vos 4 years ago
parent
commit
09e350821b

+ 13 - 2
frontend/src/mixins/ScrollAndFetchHandler.vue

@@ -5,7 +5,8 @@ export default {
 			position: 1,
 			maxPosition: 1,
 			gettingSet: false,
-			loadAllSongs: false
+			loadAllSongs: false,
+			interval: null
 		};
 	},
 	computed: {
@@ -29,8 +30,18 @@ export default {
 		},
 		loadAll() {
 			this.loadAllSongs = true;
-			this.getSet();
+			this.interval = setInterval(() => {
+				if (this.loadAllSongs && this.maxPosition > this.position)
+					this.getSet();
+				else {
+					clearInterval(this.interval);
+					this.loadAllSongs = false;
+				}
+			}, 500);
 		}
+	},
+	unmounted() {
+		clearInterval(this.interval);
 	}
 };
 </script>

+ 0 - 8
frontend/src/pages/Admin/tabs/QueueSongs.vue

@@ -201,14 +201,6 @@ export default {
 				this.maxPosition = Math.ceil(length / 15) + 1;
 
 				this.getSet();
-
-				setTimeout(() => {
-					if (
-						!this.loadAllSongs &&
-						this.maxPosition > this.position - 1
-					)
-						this.getSet();
-				}, 1000);
 			});
 
 			this.socket.emit("apis.joinAdminRoom", "queue", () => {});

+ 0 - 8
frontend/src/pages/Admin/tabs/Songs.vue

@@ -179,14 +179,6 @@ export default {
 				this.maxPosition = Math.ceil(length / 15) + 1;
 
 				this.getSet();
-
-				setTimeout(() => {
-					if (
-						!this.loadAllSongs &&
-						this.maxPosition > this.position - 1
-					)
-						this.getSet();
-				}, 1000);
 			});
 
 			this.socket.emit("apis.joinAdminRoom", "songs", () => {});