|
|
@@ -87,6 +87,7 @@ document.addEventListener("alpine:init", () => {
|
|
|
.map((video, index) => ({
|
|
|
...video,
|
|
|
originalIndex: currentIndex + index,
|
|
|
+ doneButtonText: video.status === "done" ? "Remove Done Status" : "Mark as Done",
|
|
|
}));
|
|
|
|
|
|
return {
|
|
|
@@ -107,7 +108,10 @@ document.addEventListener("alpine:init", () => {
|
|
|
) {
|
|
|
this.currentPlaylistVideos = [];
|
|
|
} else {
|
|
|
- this.currentPlaylistVideos = this.playlists[this.currentPlaylistName];
|
|
|
+ this.currentPlaylistVideos = this.playlists[this.currentPlaylistName].map((video) => ({
|
|
|
+ ...video,
|
|
|
+ doneButtonText: video.status === "done" ? "Remove Done Status" : "Mark as Done",
|
|
|
+ }));
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -361,6 +365,40 @@ document.addEventListener("alpine:init", () => {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ async toggleVideoDoneStatus(playlistName, index) {
|
|
|
+ const playlists = JSON.parse(JSON.stringify(this.playlists));
|
|
|
+ const playlist = [...playlists[playlistName]];
|
|
|
+ const video = {...playlist[index]};
|
|
|
+
|
|
|
+ // Toggle the done status
|
|
|
+ if (video.status === "done") {
|
|
|
+ // Remove status property (undefined status means not done)
|
|
|
+ delete video.status;
|
|
|
+ } else {
|
|
|
+ // Set status to done
|
|
|
+ video.status = "done";
|
|
|
+ }
|
|
|
+
|
|
|
+ // Update the video in the playlist
|
|
|
+ playlist[index] = video;
|
|
|
+
|
|
|
+ // Create an updated playlists object
|
|
|
+ const updatedPlaylists = {
|
|
|
+ ...playlists,
|
|
|
+ [playlistName]: playlist,
|
|
|
+ };
|
|
|
+
|
|
|
+ // Update the playlists in storage
|
|
|
+ try {
|
|
|
+ await browser.storage.local.set({ playlists: updatedPlaylists });
|
|
|
+ this.playlists = updatedPlaylists;
|
|
|
+ this.updatePlaylistsForDisplay();
|
|
|
+ this.updateCurrentPlaylistVideos();
|
|
|
+ } catch (error) {
|
|
|
+ console.error("Error toggling video done status:", error);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
async addCurrentPageToPlaylist() {
|
|
|
if (
|
|
|
!this.currentTab ||
|
|
|
@@ -454,6 +492,11 @@ document.addEventListener("alpine:init", () => {
|
|
|
return index < currentIndex;
|
|
|
},
|
|
|
|
|
|
+ isVideoDone(playlistName, index) {
|
|
|
+ const video = this.playlists[playlistName] && this.playlists[playlistName][index];
|
|
|
+ return video && video.status === "done";
|
|
|
+ },
|
|
|
+
|
|
|
videoItemClass: {
|
|
|
[":class"]() {
|
|
|
const playlistName = this.$el.dataset.playlistName;
|
|
|
@@ -478,6 +521,16 @@ document.addEventListener("alpine:init", () => {
|
|
|
},
|
|
|
},
|
|
|
|
|
|
+ toggleVideoDoneButton: {
|
|
|
+ ["@click"]() {
|
|
|
+ this.toggleVideoDoneStatus(
|
|
|
+ this.$el.dataset.playlistName,
|
|
|
+ parseInt(this.$el.dataset.playlistIndex),
|
|
|
+ );
|
|
|
+ this.closeAllMenus();
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
moveUpButton: {
|
|
|
["@click"]() {
|
|
|
this.moveVideoUp(
|