Browse Source

refactor: Removed unused admin/songs related code

Owen Diffey 3 years ago
parent
commit
3c9e20a33c

+ 0 - 31
backend/logic/actions/songs.js

@@ -170,37 +170,6 @@ export default {
 		);
 	}),
 
-	/**
-	 * Gets a set of songs
-	 *
-	 * @param {object} session - the session object automatically added by the websocket
-	 * @param set - the set number to return
-	 * @param cb
-	 */
-	getSet: isAdminRequired(async function getSet(session, set, cb) {
-		const songModel = await DBModule.runJob("GET_MODEL", { modelName: "song" }, this);
-		async.waterfall(
-			[
-				next => {
-					songModel
-						.find({})
-						.skip(15 * (set - 1))
-						.limit(15)
-						.exec(next);
-				}
-			],
-			async (err, songs) => {
-				if (err) {
-					err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
-					this.log("ERROR", "SONGS_GET_SET", `Failed to get set from songs. "${err}"`);
-					return cb({ status: "error", message: err });
-				}
-				this.log("SUCCESS", "SONGS_GET_SET", `Got set from songs successfully.`);
-				return cb({ status: "success", message: "Successfully got set of songs.", data: { songs } });
-			}
-		);
-	}),
-
 	/**
 	 * Gets songs, used in the admin songs page by the AdvancedTable component
 	 *

+ 0 - 51
frontend/src/mixins/ScrollAndFetchHandler.vue

@@ -1,51 +0,0 @@
-<script>
-export default {
-	data() {
-		return {
-			position: 1,
-			maxPosition: 1,
-			isGettingSet: false,
-			loadAllSongs: false,
-			interval: null
-		};
-	},
-	computed: {
-		setsLoaded() {
-			return this.position - 1;
-		},
-		maxSets() {
-			return this.maxPosition - 1;
-		}
-	},
-	mounted() {
-		window.addEventListener("scroll", this.handleScroll);
-	},
-	unmounted() {
-		clearInterval(this.interval);
-		window.removeEventListener("scroll", this.handleScroll);
-	},
-	methods: {
-		handleScroll() {
-			const scrollPosition = document.body.clientHeight + window.scrollY;
-			const bottomPosition = document.body.scrollHeight;
-
-			if (this.loadAllSongs) return false;
-
-			if (scrollPosition + 400 >= bottomPosition) this.getSet();
-
-			return this.maxPosition === this.position;
-		},
-		loadAll() {
-			this.loadAllSongs = true;
-			this.interval = setInterval(() => {
-				if (this.loadAllSongs && this.maxPosition > this.position)
-					this.getSet();
-				else {
-					clearInterval(this.interval);
-					this.loadAllSongs = false;
-				}
-			}, 500);
-		}
-	}
-};
-</script>

+ 0 - 2
frontend/src/pages/Profile/Tabs/RecentActivity.vue

@@ -154,8 +154,6 @@ export default {
 			const scrollPosition = document.body.clientHeight + window.scrollY;
 			const bottomPosition = document.body.scrollHeight;
 
-			if (this.loadAllSongs) return false;
-
 			if (scrollPosition + 400 >= bottomPosition) this.getSet();
 
 			return this.maxPosition === this.position;

+ 3 - 28
frontend/src/store/modules/admin.js

@@ -11,35 +11,10 @@ const mutations = {};
 const modules = {
 	songs: {
 		namespaced: true,
-		state: {
-			songs: []
-		},
+		state: {},
 		getters: {},
-		actions: {
-			resetSongs: ({ commit }) => commit("resetSongs"),
-			addSong: ({ commit }, song) => commit("addSong", song),
-			removeSong: ({ commit }, songId) => commit("removeSong", songId),
-			updateSong: ({ commit }, updatedSong) =>
-				commit("updateSong", updatedSong)
-		},
-		mutations: {
-			resetSongs(state) {
-				state.songs = [];
-			},
-			addSong(state, song) {
-				if (!state.songs.find(s => s._id === song._id))
-					state.songs.push(song);
-			},
-			removeSong(state, songId) {
-				state.songs = state.songs.filter(song => song._id !== songId);
-			},
-			updateSong(state, updatedSong) {
-				state.songs.forEach((song, index) => {
-					if (song._id === updatedSong._id)
-						state.songs[index] = updatedSong;
-				});
-			}
-		}
+		actions: {},
+		mutations: {}
 	},
 	stations: {
 		namespaced: true,