Browse Source

Fixed report modal not showing previous song

Owen Diffey 3 years ago
parent
commit
638eb2474c
2 changed files with 15 additions and 55 deletions
  1. 1 2
      backend/logic/youtube.js
  2. 14 53
      frontend/src/components/modals/Report.vue

+ 1 - 2
backend/logic/youtube.js

@@ -305,9 +305,8 @@ class _YouTubeModule extends CoreClass {
 						YouTubeModule.log("ERROR", "GET_PLAYLIST_PAGE", `${err.message}`);
 						if (err.message === "Request failed with status code 404") {
 							return reject(new Error("Playlist not found. Is the playlist public/unlisted?"));
-						} else {
-							return reject(new Error("An error has occured. Please try again later."));
 						}
+						return reject(new Error("An error has occured. Please try again later."));
 					});
 			});
 		});

+ 14 - 53
frontend/src/components/modals/Report.vue

@@ -2,10 +2,7 @@
 	<modal title="Report">
 		<div slot="body">
 			<div class="columns song-types">
-				<div
-					v-if="previousSong !== null && localSong === null"
-					class="column song-type"
-				>
+				<div v-if="previousSong !== null" class="column song-type">
 					<div
 						class="card is-fullwidth"
 						:class="{ 'is-highlight-active': isPreviousSongActive }"
@@ -44,35 +41,32 @@
 						/>
 					</div>
 				</div>
-				<div
-					v-if="currentSong !== {} && localSong === null"
-					class="column song-type"
-				>
+				<div v-if="localSong !== null" class="column song-type">
 					<div
 						class="card is-fullwidth"
-						:class="{ 'is-highlight-active': isCurrentSongActive }"
-						@click="highlight('currentSong')"
+						:class="{ 'is-highlight-active': isLocalSongActive }"
+						@click="highlight('localSong')"
 					>
 						<header class="card-header">
-							<p class="card-header-title">Current Song</p>
+							<p class="card-header-title">Selected Song</p>
 						</header>
 						<div class="card-content">
 							<article class="media">
 								<figure class="media-left">
 									<song-thumbnail
 										class="image is-64x64"
-										:song="currentSong"
+										:song="localSong"
 									/>
 								</figure>
 								<div class="media-content">
 									<div class="content">
 										<p>
 											<strong>{{
-												currentSong.title
+												localSong.title
 											}}</strong>
 											<br />
 											<small>{{
-												currentSong.artists.join(", ")
+												localSong.artists.join(", ")
 											}}</small>
 										</p>
 									</div>
@@ -82,40 +76,10 @@
 						<a
 							href="#"
 							class="absolute-a"
-							@click="highlight('currentSong')"
+							@click="highlight('localSong')"
 						/>
 					</div>
 				</div>
-				<div v-if="localSong !== null" class="column song-type">
-					<div class="card is-fullwidth">
-						<header class="card-header">
-							<p class="card-header-title">Song</p>
-						</header>
-						<div class="card-content">
-							<article class="media">
-								<figure class="media-left">
-									<song-thumbnail
-										class="image is-64x64"
-										:song="localSong"
-									/>
-								</figure>
-								<div class="media-content">
-									<div class="content">
-										<p>
-											<strong>{{
-												localSong.title
-											}}</strong>
-											<br />
-											<small>{{
-												localSong.artists.join(", ")
-											}}</small>
-										</p>
-									</div>
-								</div>
-							</article>
-						</div>
-					</div>
-				</div>
 			</div>
 			<div class="edit-report-wrapper">
 				<div class="columns is-multiline">
@@ -187,7 +151,7 @@ export default {
 	data() {
 		return {
 			isPreviousSongActive: false,
-			isCurrentSongActive: true,
+			isLocalSongActive: true,
 			localSong: null,
 			report: {
 				resolved: false,
@@ -240,7 +204,6 @@ export default {
 			return 400 - this.report.description.length;
 		},
 		...mapState({
-			currentSong: state => state.station.currentSong,
 			previousSong: state => state.station.previousSong,
 			song: state => state.modals.report.song
 		}),
@@ -249,8 +212,6 @@ export default {
 		})
 	},
 	mounted() {
-		this.report.songId = this.currentSong.songId;
-
 		if (this.song !== null) {
 			this.localSong = this.song;
 			this.report.songId = this.song.songId;
@@ -269,13 +230,13 @@ export default {
 			});
 		},
 		highlight(type) {
-			if (type === "currentSong") {
-				this.report.songId = this.currentSong.songId;
+			if (type === "localSong") {
+				this.report.songId = this.localSong.songId;
 				this.isPreviousSongActive = false;
-				this.isCurrentSongActive = true;
+				this.isLocalSongActive = true;
 			} else if (type === "previousSong") {
 				this.report.songId = this.previousSong.songId;
-				this.isCurrentSongActive = false;
+				this.isLocalSongActive = false;
 				this.isPreviousSongActive = true;
 			}
 		},