فهرست منبع

Re-added ability to report previous song in station

Owen Diffey 3 سال پیش
والد
کامیت
6d82c102e2
3فایلهای تغییر یافته به همراه28 افزوده شده و 2 حذف شده
  1. 13 2
      frontend/src/components/modals/Report.vue
  2. 7 0
      frontend/src/pages/Station/index.vue
  3. 8 0
      frontend/src/store/modules/station.js

+ 13 - 2
frontend/src/components/modals/Report.vue

@@ -198,6 +198,15 @@
 				>
 				>
 					<span>&nbsp;Cancel</span>
 					<span>&nbsp;Cancel</span>
 				</a>
 				</a>
+				<div class="right">
+					<a
+						v-if="previousSong !== null && song !== previousSong"
+						class="button is-primary"
+						@click="reportSong(previousSong)"
+					>
+						<span>&nbsp;Report Previous Song</span>
+					</a>
+				</div>
 			</template>
 			</template>
 		</modal>
 		</modal>
 		<view-report v-if="modals.viewReport" />
 		<view-report v-if="modals.viewReport" />
@@ -348,7 +357,8 @@ export default {
 	},
 	},
 	computed: {
 	computed: {
 		...mapState({
 		...mapState({
-			song: state => state.modals.report.song
+			song: state => state.modals.report.song,
+			previousSong: state => state.station.previousSong
 		}),
 		}),
 		...mapState("modalVisibility", {
 		...mapState("modalVisibility", {
 			modals: state => state.modals
 			modals: state => state.modals
@@ -421,7 +431,8 @@ export default {
 			);
 			);
 		},
 		},
 		...mapActions("modalVisibility", ["openModal", "closeModal"]),
 		...mapActions("modalVisibility", ["openModal", "closeModal"]),
-		...mapActions("modals/viewReport", ["viewReport"])
+		...mapActions("modals/viewReport", ["viewReport"]),
+		...mapActions("modals/report", ["reportSong"])
 	}
 	}
 };
 };
 </script>
 </script>

+ 7 - 0
frontend/src/pages/Station/index.vue

@@ -1048,6 +1048,12 @@ export default {
 		);
 		);
 
 
 		this.socket.on("event:station.nextSong", res => {
 		this.socket.on("event:station.nextSong", res => {
+			const previousSong = this.currentSong.youtubeId
+				? this.currentSong
+				: null;
+
+			this.updatePreviousSong(previousSong);
+
 			const { currentSong, startedAt, paused, timePaused } = res.data;
 			const { currentSong, startedAt, paused, timePaused } = res.data;
 
 
 			this.setCurrentSong({
 			this.setCurrentSong({
@@ -2298,6 +2304,7 @@ export default {
 			"updateUserCount",
 			"updateUserCount",
 			"updateUsers",
 			"updateUsers",
 			"updateCurrentSong",
 			"updateCurrentSong",
+			"updatePreviousSong",
 			"updateNextSong",
 			"updateNextSong",
 			"updateSongsList",
 			"updateSongsList",
 			"repositionSongInList",
 			"repositionSongInList",

+ 8 - 0
frontend/src/store/modules/station.js

@@ -10,6 +10,7 @@ const state = {
 		loggedOut: []
 		loggedOut: []
 	},
 	},
 	currentSong: {},
 	currentSong: {},
+	previousSong: null,
 	nextSong: null,
 	nextSong: null,
 	songsList: [],
 	songsList: [],
 	stationPaused: true,
 	stationPaused: true,
@@ -40,6 +41,9 @@ const actions = {
 	updateCurrentSong: ({ commit }, currentSong) => {
 	updateCurrentSong: ({ commit }, currentSong) => {
 		commit("updateCurrentSong", currentSong);
 		commit("updateCurrentSong", currentSong);
 	},
 	},
+	updatePreviousSong: ({ commit }, previousSong) => {
+		commit("updatePreviousSong", previousSong);
+	},
 	updateNextSong: ({ commit }, nextSong) => {
 	updateNextSong: ({ commit }, nextSong) => {
 		commit("updateNextSong", nextSong);
 		commit("updateNextSong", nextSong);
 	},
 	},
@@ -98,6 +102,7 @@ const mutations = {
 			loggedOut: []
 			loggedOut: []
 		};
 		};
 		state.currentSong = {};
 		state.currentSong = {};
+		state.previousSong = null;
 		state.nextSong = null;
 		state.nextSong = null;
 		state.songsList = [];
 		state.songsList = [];
 		state.stationPaused = true;
 		state.stationPaused = true;
@@ -118,6 +123,9 @@ const mutations = {
 	updateCurrentSong(state, currentSong) {
 	updateCurrentSong(state, currentSong) {
 		state.currentSong = currentSong;
 		state.currentSong = currentSong;
 	},
 	},
+	updatePreviousSong(state, previousSong) {
+		state.previousSong = previousSong;
+	},
 	updateNextSong(state, nextSong) {
 	updateNextSong(state, nextSong) {
 		state.nextSong = nextSong;
 		state.nextSong = nextSong;
 	},
 	},