Преглед изворни кода

refactor: more changes to hide actions for SoundCloud songs when disabled, and allow deleting from playlist always

Kristian Vos пре 1 година
родитељ
комит
1dfdc914ae

+ 14 - 11
backend/logic/actions/playlists.js

@@ -2532,17 +2532,20 @@ export default {
 				},
 
 				(playlist, next) => {
-					MediaModule.runJob("GET_MEDIA", { mediaSource }, this)
-						.then(res =>
-							next(null, playlist, {
-								_id: res.song._id,
-								title: res.song.title,
-								thumbnail: res.song.thumbnail,
-								artists: res.song.artists,
-								mediaSource: res.song.mediaSource
-							})
-						)
-						.catch(next);
+					let normalizedSong = null;
+
+					const song = playlist.songs.find(song => song.mediaSource === mediaSource);
+					if (song) {
+						normalizedSong = {
+							_id: song._id,
+							title: song.title,
+							thumbnail: song.thumbnail,
+							artists: song.artists,
+							mediaSource: song.mediaSource
+						};
+					}
+
+					next(null, playlist, normalizedSong);
 				},
 
 				(playlist, newSong, next) => {

+ 1 - 6
frontend/src/components/MediaItem.vue

@@ -263,12 +263,7 @@ onUnmounted(() => {
 			</p>
 			<div
 				class="universal-item-actions"
-				v-if="
-					disabledActions.indexOf('all') === -1 &&
-					(songMediaType !== 'soundcloud' ||
-						experimental.soundcloud ||
-						song._id)
-				"
+				v-if="disabledActions.indexOf('all') === -1"
 			>
 				<tippy
 					v-if="loggedIn && hoveredTippy"

+ 7 - 2
frontend/src/components/modals/EditPlaylist/index.vue

@@ -37,6 +37,7 @@ const props = defineProps({
 
 const { socket } = useWebsocketsStore();
 const configStore = useConfigStore();
+const { experimental } = configStore;
 const editPlaylistStore = useEditPlaylistStore({ modalUuid: props.modalUuid });
 const stationStore = useStationStore();
 const userAuthStore = useUserAuthStore();
@@ -451,7 +452,7 @@ onBeforeUnmount(() => {
 								>
 									<template #tippyActions>
 										<i
-											class="material-icons add-to-queue-icon"
+											class="material-icons add-to-queue-icon kris111"
 											v-if="
 												station &&
 												station.requests &&
@@ -462,7 +463,11 @@ onBeforeUnmount(() => {
 														'owner' &&
 														(userRole === 'admin' ||
 															station.owner ===
-																userId)))
+																userId))) &&
+												(element.mediaSource.split(
+													':'
+												)[0] !== 'soundcloud' ||
+													experimental.soundcloud)
 											"
 											@click="
 												addSongToQueue(

+ 7 - 0
frontend/src/pages/Station/Sidebar/History.vue

@@ -111,6 +111,13 @@ onMounted(async () => {});
 			<media-item
 				:song="historyItem.payload.song"
 				:requested-by="true"
+				:disabled-actions="
+					historyItem.payload.song.mediaSource.startsWith(
+						'soundcloud:'
+					) && !experimental.soundcloud
+						? ['all']
+						: []
+				"
 				:header="`Finished playing at ${formatDate(
 					historyItem.payload.skippedAt
 				)}${formatSkipReason(historyItem.payload.skipReason)}`"