Skip to content
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

Merged
merged 6 commits into from
Jan 20, 2025

Conversation

Soham456
Copy link
Contributor

@Soham456 Soham456 commented Oct 17, 2024

Pull Request Type

  • Feature Implementation

Related issue

closes #5421

Additional context

resolved yarn.lock conflict

@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Oct 17, 2024
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) October 17, 2024 09:43
@absidue absidue added the DO NOT MERGE UNTIL AFTER RELEASE Do not merge before the next release as this is not a bug fix label Oct 17, 2024
@absidue
Copy link
Member

absidue commented Oct 22, 2024

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.

@efb4f5ff-1298-471a-8973-3d47447115dc efb4f5ff-1298-471a-8973-3d47447115dc added PR: changes requested and removed PR: waiting for review For PRs that are complete, tested, and ready for review DO NOT MERGE UNTIL AFTER RELEASE Do not merge before the next release as this is not a bug fix labels Oct 23, 2024
@absidue absidue added DO NOT MERGE UNTIL AFTER RELEASE Do not merge before the next release as this is not a bug fix and removed DO NOT MERGE UNTIL AFTER RELEASE Do not merge before the next release as this is not a bug fix labels Oct 23, 2024
auto-merge was automatically disabled October 27, 2024 15:00

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) October 27, 2024 15:00
@Soham456 Soham456 requested a review from absidue October 28, 2024 09:17
@ChunkyProgrammer ChunkyProgrammer added PR: waiting for review For PRs that are complete, tested, and ready for review and removed PR: changes requested labels Nov 3, 2024
Copy link
Collaborator

@PikachuEXE PikachuEXE left a 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

src/renderer/views/Playlist/Playlist.js Outdated Show resolved Hide resolved
src/renderer/views/Playlist/Playlist.js Outdated Show resolved Hide resolved
@absidue absidue added PR: changes requested and removed PR: waiting for review For PRs that are complete, tested, and ready for review labels Nov 3, 2024
auto-merge was automatically disabled November 16, 2024 11:47

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) November 16, 2024 11:48
auto-merge was automatically disabled November 16, 2024 12:21

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) November 16, 2024 12:21
@Soham456 Soham456 requested a review from PikachuEXE November 16, 2024 12:24
Copy link
Collaborator

@PikachuEXE PikachuEXE left a 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

auto-merge was automatically disabled November 17, 2024 12:47

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) November 17, 2024 12:48
@Soham456 Soham456 requested a review from PikachuEXE January 6, 2025 05:02
@PikachuEXE
Copy link
Collaborator

Merge conflict must be solved before we can review

auto-merge was automatically disabled January 6, 2025 09:34

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) January 6, 2025 09:34
auto-merge was automatically disabled January 6, 2025 09:38

Head branch was pushed to by a user without write access

Copy link
Contributor

github-actions bot commented Jan 6, 2025

Conflicts have been resolved. A maintainer will review the pull request shortly.

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) January 6, 2025 09:39
Copy link
Collaborator

@PikachuEXE PikachuEXE left a 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')
         }

patch.diff.txt

auto-merge was automatically disabled January 9, 2025 08:49

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) January 9, 2025 08:50
@Soham456 Soham456 requested a review from PikachuEXE January 9, 2025 08:53
@PikachuEXE PikachuEXE added PR: waiting for review For PRs that are complete, tested, and ready for review and removed PR: changes requested labels Jan 10, 2025
@PikachuEXE PikachuEXE requested review from efb4f5ff-1298-471a-8973-3d47447115dc and absidue and removed request for absidue January 10, 2025 00:45
@FreeTubeBot FreeTubeBot merged commit 3b84a86 into FreeTubeApp:development Jan 20, 2025
6 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Jan 20, 2025
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Jan 21, 2025
* 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)
  ...
SuperAKWA pushed a commit to SuperAKWA/FreeTube that referenced this pull request Jan 24, 2025
* changed logic to work with Custom as well.

* updated removeVideos

* linted

* resolving conflict

* updated changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Undo for "Remove from Playlist"
6 participants