|
@@ -97,15 +97,15 @@ const isEditable = permission =>
|
|
permission === "playlists.update.privacy" &&
|
|
permission === "playlists.update.privacy" &&
|
|
hasPermission(permission));
|
|
hasPermission(permission));
|
|
|
|
|
|
-const repositionSong = ({ moved }) => {
|
|
+const repositionSong = ({ moved, song }) => {
|
|
const { oldIndex, newIndex } = moved;
|
|
const { oldIndex, newIndex } = moved;
|
|
if (oldIndex === newIndex) return; // we only need to update when song is moved
|
|
if (oldIndex === newIndex) return; // we only need to update when song is moved
|
|
- const song = playlistSongs.value[newIndex];
|
|
+ const _song = song ?? playlistSongs.value[newIndex];
|
|
socket.dispatch(
|
|
socket.dispatch(
|
|
"playlists.repositionSong",
|
|
"playlists.repositionSong",
|
|
playlist.value._id,
|
|
playlist.value._id,
|
|
{
|
|
{
|
|
- ...song,
|
|
+ ..._song,
|
|
oldIndex,
|
|
oldIndex,
|
|
newIndex
|
|
newIndex
|
|
},
|
|
},
|
|
@@ -115,27 +115,23 @@ const repositionSong = ({ moved }) => {
|
|
|
|
|
|
const moveSongToTop = index => {
|
|
const moveSongToTop = index => {
|
|
songItems.value[`song-item-${index}`].$refs.songActions.tippy.hide();
|
|
songItems.value[`song-item-${index}`].$refs.songActions.tippy.hide();
|
|
- playlistSongs.value.splice(0, 0, playlistSongs.value.splice(index, 1)[0]);
|
|
|
|
repositionSong({
|
|
repositionSong({
|
|
moved: {
|
|
moved: {
|
|
oldIndex: index,
|
|
oldIndex: index,
|
|
newIndex: 0
|
|
newIndex: 0
|
|
- }
|
|
+ },
|
|
|
|
+ song: playlistSongs.value[index]
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
const moveSongToBottom = index => {
|
|
const moveSongToBottom = index => {
|
|
songItems.value[`song-item-${index}`].$refs.songActions.tippy.hide();
|
|
songItems.value[`song-item-${index}`].$refs.songActions.tippy.hide();
|
|
- playlistSongs.value.splice(
|
|
|
|
- playlistSongs.value.length - 1,
|
|
|
|
- 0,
|
|
|
|
- playlistSongs.value.splice(index, 1)[0]
|
|
|
|
- );
|
|
|
|
repositionSong({
|
|
repositionSong({
|
|
moved: {
|
|
moved: {
|
|
oldIndex: index,
|
|
oldIndex: index,
|
|
newIndex: playlistSongs.value.length - 1
|
|
newIndex: playlistSongs.value.length - 1
|
|
- }
|
|
+ },
|
|
|
|
+ song: playlistSongs.value[index]
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|