Skip to content

Commit

Permalink
Make playlist import match existing playlist by ID first (FreeTubeApp…
Browse files Browse the repository at this point in the history
…#6094)

* * Make playlist import match exisitng playlist by ID first

* * Update some playlist attribuites too during import for existing playlists
  • Loading branch information
PikachuEXE authored and Alban Dumas committed Jan 24, 2025
1 parent 1c70b24 commit edbca29
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/renderer/components/data-settings/data-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,12 @@ export default defineComponent({
]

const optionalKeys = [
'_id',
'description',
'createdAt',
]

const ignoredKeys = [
'_id',
'title',
'type',
'protected',
Expand Down Expand Up @@ -910,6 +910,10 @@ export default defineComponent({
}

const existingPlaylist = this.allPlaylists.find((playlist) => {
if (playlistObject._id != null && playlist._id === playlistObject._id) {
return true
}

return playlist.playlistName === playlistObject.playlistName
})

Expand Down Expand Up @@ -957,8 +961,13 @@ export default defineComponent({
this.addVideo(payload)
}
})
// Update playlist's `lastUpdatedAt`
this.updatePlaylist({ _id: existingPlaylist._id })
// Update playlist's `lastUpdatedAt` & other attributes
this.updatePlaylist({
_id: existingPlaylist._id,
// Only these attributes would be updated (besides videos)
playlistName: playlistObject.playlistName,
description: playlistObject.description,
})
})

showToast(this.$t('Settings.Data Settings.All playlists has been successfully imported'))
Expand Down

0 comments on commit edbca29

Please sign in to comment.