-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undo Feature For Remove From Playlist. #5885
Conversation
Could you please also undo the changes to the unrelated files? This time please do it in this pull request instead of closing and creating a duplicate one. |
Head branch was pushed to by a user without write access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a file telling editor to use spaces instead of tabs for indent
https://github.com/FreeTubeApp/FreeTube/blob/development/.editorconfig
Please setup your editor (info at https://editorconfig.org) and fix those tabs
Head branch was pushed to by a user without write access
Head branch was pushed to by a user without write access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In src/renderer/views/Playlist/Playlist.vue
there is another usage of removeVideoFromPlaylist
that should be updated
Head branch was pushed to by a user without write access
Merge conflict must be solved before we can review |
Head branch was pushed to by a user without write access
Head branch was pushed to by a user without write access
Conflicts have been resolved. A maintainer will review the pull request shortly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Video IDs not needed when playlist item IDs already present
- Missing sync in other windows
There are changes needed in unchanged files so posting diff here:
diff
diff --git a/src/constants.js b/src/constants.js
index f13891fb5..3bc4f2d50 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -107,6 +107,7 @@ const SyncEvents = {
UPSERT_VIDEO: 'sync-playlists-upsert-video',
UPSERT_VIDEOS: 'sync-playlists-upsert-videos',
DELETE_VIDEO: 'sync-playlists-delete-video',
+ DELETE_VIDEOS: 'sync-playlists-delete-videos',
},
SUBSCRIPTION_CACHE: {
diff --git a/src/datastores/handlers/base.js b/src/datastores/handlers/base.js
index 9acbbd57a..81e27544e 100644
--- a/src/datastores/handlers/base.js
+++ b/src/datastores/handlers/base.js
@@ -201,10 +201,10 @@ class Playlists {
}
}
- static deleteVideoIdsByPlaylistId(_id, videoDataIds) {
+ static deleteVideoIdsByPlaylistId(_id, playlistItemIds) {
return db.playlists.updateAsync(
{ _id },
- { $pull: { videos: { videoId: { $in: videoDataIds.videoIds }, playlistItemId: { $in: videoDataIds.playlistItemIds } } } },
+ { $pull: { videos: { playlistItemId: { $in: playlistItemIds } } } },
{ upsert: true }
)
}
diff --git a/src/datastores/handlers/electron.js b/src/datastores/handlers/electron.js
index b18706ec8..8b00e752e 100644
--- a/src/datastores/handlers/electron.js
+++ b/src/datastores/handlers/electron.js
@@ -183,12 +183,12 @@ class Playlists {
)
}
- static deleteVideoIdsByPlaylistId(_id, videoIds) {
+ static deleteVideoIdsByPlaylistId(_id, playlistItemIds) {
return ipcRenderer.invoke(
IpcChannels.DB_PLAYLISTS,
{
action: DBActions.PLAYLISTS.DELETE_VIDEO_IDS,
- data: { _id, videoIds }
+ data: { _id, playlistItemIds }
}
)
}
diff --git a/src/main/index.js b/src/main/index.js
index 4b9a8c2d2..81311e8eb 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -1308,9 +1308,12 @@ function runApp() {
return null
case DBActions.PLAYLISTS.DELETE_VIDEO_IDS:
- await baseHandlers.playlists.deleteVideoIdsByPlaylistId(data._id, data.videoIds)
- // TODO: Syncing (implement only when it starts being used)
- // syncOtherWindows(IpcChannels.SYNC_PLAYLISTS, event, { event: '_', data })
+ await baseHandlers.playlists.deleteVideoIdsByPlaylistId(data._id, data.playlistItemIds)
+ syncOtherWindows(
+ IpcChannels.SYNC_PLAYLISTS,
+ event,
+ { event: SyncEvents.PLAYLISTS.DELETE_VIDEOS, data }
+ )
return null
case DBActions.PLAYLISTS.DELETE_ALL_VIDEOS:
diff --git a/src/renderer/store/modules/playlists.js b/src/renderer/store/modules/playlists.js
index a7738b62b..d0780eaa7 100644
--- a/src/renderer/store/modules/playlists.js
+++ b/src/renderer/store/modules/playlists.js
@@ -417,8 +417,8 @@ const actions = {
async removeVideos({ commit }, payload) {
try {
- const { _id, videoIds, playlistItemIds } = payload
- await DBPlaylistHandlers.deleteVideoIdsByPlaylistId(_id, { videoIds: videoIds, playlistItemIds: playlistItemIds })
+ const { _id, playlistItemIds } = payload
+ await DBPlaylistHandlers.deleteVideoIdsByPlaylistId(_id, playlistItemIds)
commit('removeVideos', payload)
} catch (errMessage) {
console.error(errMessage)
@@ -484,13 +484,12 @@ const mutations = {
}
},
- removeVideos(state, { _id, videoIds, playlistItemIds }) {
+ removeVideos(state, { _id, playlistItemIds }) {
const playlist = state.playlists.find(playlist => playlist._id === _id)
if (playlist) {
playlist.videos = playlist.videos.filter(video => {
- const videoIdMatches = videoIds.includes(video.videoId)
const playlistItemIdMatches = playlistItemIds.includes(video.playlistItemId)
- return !(videoIdMatches && playlistItemIdMatches)
+ return !playlistItemIdMatches
})
}
},
diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js
index db14a1399..fe1e4cb08 100644
--- a/src/renderer/store/modules/settings.js
+++ b/src/renderer/store/modules/settings.js
@@ -553,6 +553,10 @@ const customActions = {
commit('removeVideo', data)
break
+ case SyncEvents.PLAYLISTS.DELETE_VIDEOS:
+ commit('removeVideos', data)
+ break
+
default:
console.error('playlists: invalid sync event received')
}
Head branch was pushed to by a user without write access
* development: (23 commits) Translated using Weblate (Czech) Translated using Weblate (German) Translated using Weblate (Basque) Translated using Weblate (Ukrainian) Translated using Weblate (German) Translated using Weblate (Basque) Translated using Weblate (German) Stay in fullscreen/fullwindow/PiP + default viewing mode setting (FreeTubeApp#5903) Undo Feature For Remove From Playlist. (FreeTubeApp#5885) group builds (FreeTubeApp#6497) Change CREATE_NEW_WINDOW IPC call to accept a path and query (FreeTubeApp#6595) Bump shaka-player from 4.12.7 to 4.12.8 (FreeTubeApp#6609) Bump electron from 33.3.1 to 34.0.0 (FreeTubeApp#6608) Translated using Weblate (French) Bump sass from 1.83.1 to 1.83.4 (FreeTubeApp#6607) Bump lefthook from 1.10.3 to 1.10.9 (FreeTubeApp#6606) Bump eslint-plugin-jsdoc from 50.6.1 to 50.6.2 in the eslint group (FreeTubeApp#6604) Translated using Weblate (Czech) Translated using Weblate (Estonian) Translated using Weblate (German) ...
* changed logic to work with Custom as well. * updated removeVideos * linted * resolving conflict * updated changes
Pull Request Type
Related issue
closes #5421
Additional context
resolved yarn.lock conflict