ソースを参照

refactor: Hide unavailable soundcloud media item actions

Owen Diffey 1 年間 前
コミット
c5600202a2

+ 11 - 10
backend/logic/stations.js

@@ -303,20 +303,19 @@ class _StationsModule extends CoreClass {
 									.then()
 									.catch();
 
-								if (station.paused) return next(true, station);
-
 								return next(null, station);
 							});
 					},
 					(station, next) => {
 						if (
-							!station.currentSong ||
-							(!config.get("experimental.soundcloud") &&
-								station.currentSong.mediaSource &&
-								station.currentSong.mediaSource.startsWith("soundcloud:")) ||
-							(!config.get("experimental.spotify") &&
-								station.currentSong.mediaSource &&
-								station.currentSong.mediaSource.startsWith("spotify:"))
+							(!station.paused && !station.currentSong) ||
+							(station.currentSong &&
+								((!config.get("experimental.soundcloud") &&
+									station.currentSong.mediaSource &&
+									station.currentSong.mediaSource.startsWith("soundcloud:")) ||
+									(!config.get("experimental.spotify") &&
+										station.currentSong.mediaSource &&
+										station.currentSong.mediaSource.startsWith("spotify:"))))
 						) {
 							return StationsModule.runJob(
 								"SKIP_STATION",
@@ -328,12 +327,14 @@ class _StationsModule extends CoreClass {
 								this
 							)
 								.then(station => {
-									next(true, station);
+									next(null, station);
 								})
 								.catch(next)
 								.finally(() => {});
 						}
 
+						if (station.paused) return next(null, station);
+
 						let timeLeft =
 							station.currentSong.duration * 1000 - (Date.now() - station.startedAt - station.timePaused);
 

+ 11 - 3
frontend/src/components/MediaItem.vue

@@ -263,7 +263,12 @@ onUnmounted(() => {
 			</p>
 			<div
 				class="universal-item-actions"
-				v-if="disabledActions.indexOf('all') === -1"
+				v-if="
+					disabledActions.indexOf('all') === -1 &&
+					(songMediaType !== 'soundcloud' ||
+						experimental.soundcloud ||
+						song._id)
+				"
 			>
 				<tippy
 					v-if="loggedIn && hoveredTippy"
@@ -288,7 +293,8 @@ onUnmounted(() => {
 									disabledActions.indexOf('view-song') ===
 										-1 &&
 									(songMediaType === 'youtube' ||
-										songMediaType === 'soundcloud')
+										(songMediaType === 'soundcloud' &&
+											experimental.soundcloud))
 								"
 								@click="viewMedia(song.mediaSource)"
 								content="View Media"
@@ -315,7 +321,9 @@ onUnmounted(() => {
 							<add-to-playlist-dropdown
 								v-if="
 									disabledActions.indexOf('addToPlaylist') ===
-									-1
+										-1 &&
+									(songMediaType !== 'soundcloud' ||
+										experimental.soundcloud)
 								"
 								:song="song"
 								placement="top-end"

+ 25 - 1
frontend/src/pages/Station/Sidebar/History.vue

@@ -5,6 +5,8 @@ import { storeToRefs } from "pinia";
 import { useWebsocketsStore } from "@/stores/websockets";
 import { useStationStore } from "@/stores/station";
 import MediaItem from "@/components/MediaItem.vue";
+import { useConfigStore } from "@/stores/config";
+import { useUserAuthStore } from "@/stores/userAuth";
 
 const stationStore = useStationStore();
 
@@ -12,6 +14,12 @@ const { socket } = useWebsocketsStore();
 
 const { history } = storeToRefs(stationStore);
 
+const configStore = useConfigStore();
+const { experimental } = storeToRefs(configStore);
+
+const userAuthStore = useUserAuthStore();
+const { loggedIn, userId, role: userRole } = storeToRefs(userAuthStore);
+
 const station = computed({
 	get() {
 		return stationStore.station;
@@ -97,7 +105,23 @@ onMounted(async () => {});
 					historyItem.payload.skippedAt
 				)}${formatSkipReason(historyItem.payload.skipReason)}`"
 			>
-				<template #actions>
+				<template
+					v-if="
+						loggedIn &&
+						station &&
+						station.requests &&
+						station.requests.enabled &&
+						(station.requests.access === 'user' ||
+							(station.requests.access === 'owner' &&
+								(userRole === 'admin' ||
+									station.owner === userId))) &&
+						(!historyItem.payload.song.mediaSource.startsWith(
+							'soundcloud:'
+						) ||
+							experimental.soundcloud)
+					"
+					#actions
+				>
 					<transition
 						name="musare-history-query-actions"
 						mode="out-in"