From 095cd1869fc07f95257c1605879dde13ec42c032 Mon Sep 17 00:00:00 2001 From: HiImKobeAnd Date: Fri, 2 Aug 2024 20:11:10 +0200 Subject: [PATCH 1/5] feat: add mark as watched/unwatched button --- src/components/FeedPage.vue | 11 +++++++++- src/components/VideoItem.vue | 41 +++++++++++++++++++++++++++++++++++- src/locales/en.json | 2 ++ src/main.js | 5 +++++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/components/FeedPage.vue b/src/components/FeedPage.vue index bb8ac13d..35c0888d 100644 --- a/src/components/FeedPage.vue +++ b/src/components/FeedPage.vue @@ -48,7 +48,7 @@ @@ -140,6 +140,15 @@ export default { this.loadMoreVideos(); } }, + onUpdateWatched(urls = null) { + if (urls === null) { + if (this.videos.length > 0) this.updateWatched(this.videos); + return; + } + + const subset = this.videos.filter(({ url }) => urls.includes(url)); + if (subset.length > 0) this.updateWatched(subset); + }, shouldShowVideo(video) { switch (this.selectedFilter.toLowerCase()) { case "shorts": diff --git a/src/components/VideoItem.vue b/src/components/VideoItem.vue index a08b59e1..998d62a2 100644 --- a/src/components/VideoItem.vue +++ b/src/components/VideoItem.vue @@ -122,6 +122,11 @@ > + + diff --git a/src/locales/en.json b/src/locales/en.json index 0ca47400..eb73143b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -132,6 +132,8 @@ "show_chapters": "Chapters", "store_search_history": "Store Search History", "hide_watched": "Hide watched videos in the feed", + "mark_as_watched": "Mark as Watched", + "mark_as_unwatched": "Mark as Unwatched", "documentation": "Documentation", "status_page": "Status", "source_code": "Source code", diff --git a/src/main.js b/src/main.js index b7d5b187..31074170 100644 --- a/src/main.js +++ b/src/main.js @@ -144,6 +144,11 @@ const mixin = { var request = store.get(video.url.substr(-11)); request.onsuccess = function (event) { if (event.target.result) { + if (event.target.result.currentTime == 0) { + video.watched = false; + video.currentTime = event.target.result.currentTime; + return; + } video.watched = true; video.currentTime = event.target.result.currentTime; } From ab2f6839e16231ab75e7a6b4188cf223b40e8fa6 Mon Sep 17 00:00:00 2001 From: HiImKobeAnd Date: Sun, 4 Aug 2024 11:53:22 +0200 Subject: [PATCH 2/5] fix: remove from trending page and hide if watch history is diabled remove the button from trending page because it only works in feed page. --- src/components/VideoItem.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/VideoItem.vue b/src/components/VideoItem.vue index 998d62a2..456676d2 100644 --- a/src/components/VideoItem.vue +++ b/src/components/VideoItem.vue @@ -122,8 +122,11 @@ > - - @@ -183,6 +186,7 @@ export default { showShareModal: false, showVideo: true, showConfirmRemove: false, + showMarkOnWatched: false, }; }, computed: { @@ -195,6 +199,7 @@ export default { }, mounted() { this.shouldShowVideo(); + this.shouldShowMarkOnWatched(); }, methods: { removeVideo() { @@ -217,6 +222,9 @@ export default { } }; }, + shouldShowMarkOnWatched() { + this.showMarkOnWatched = this.getPreferenceBoolean("watchHistory", false); + }, toggleWatched(videoId) { if (window.db) { // Should match WatchVideo.vue From 0cbd1c8d72f3646a598377ee4182d96d8e3c3a3d Mon Sep 17 00:00:00 2001 From: hiimkobeand Date: Sun, 11 Aug 2024 17:55:58 +0200 Subject: [PATCH 3/5] fix: missing thumbnail url in watch_history when using mark as watched --- src/components/VideoItem.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/VideoItem.vue b/src/components/VideoItem.vue index 456676d2..765e56e0 100644 --- a/src/components/VideoItem.vue +++ b/src/components/VideoItem.vue @@ -242,7 +242,7 @@ export default { videoId: videoId, title: instance.item.title, duration: instance.item.duration, - thumbnail: instance.item.thumbnailUrl, + thumbnail: instance.item.thumbnail, uploaderUrl: instance.item.uploaderUrl, uploaderName: instance.item.uploader, watchedAt: Date.now(), From 4ef42f3b15f3c2fba1e0bb7501dfe9a7f329dfb4 Mon Sep 17 00:00:00 2001 From: hiimkobeand Date: Mon, 12 Aug 2024 10:49:02 +0200 Subject: [PATCH 4/5] fix: missing uploadername in watch_history when using mark as watched --- src/components/VideoItem.vue | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/components/VideoItem.vue b/src/components/VideoItem.vue index 765e56e0..474030a3 100644 --- a/src/components/VideoItem.vue +++ b/src/components/VideoItem.vue @@ -227,7 +227,6 @@ export default { }, toggleWatched(videoId) { if (window.db) { - // Should match WatchVideo.vue var tx = window.db.transaction("watch_history", "readwrite"); var store = tx.objectStore("watch_history"); var instance = this; @@ -237,23 +236,19 @@ export default { if (video) { video.watchedAt = Date.now(); } else { - // Should match WatchVideo.vue video = { videoId: videoId, title: instance.item.title, duration: instance.item.duration, thumbnail: instance.item.thumbnail, uploaderUrl: instance.item.uploaderUrl, - uploaderName: instance.item.uploader, + uploaderName: instance.item.uploaderName, watchedAt: Date.now(), }; } - // Set time to end for shouldShowVideo video.currentTime = instance.item.currentTime !== instance.item.duration ? instance.item.duration : 0; - // Save store.put(video); - // Disappear if hideWatched is on instance.$emit("update:watched", [instance.item.url]); instance.shouldShowVideo(); }; From 99bff86dfe5ad0694c4286f4c09435f68efd6c1e Mon Sep 17 00:00:00 2001 From: hiimkobeand Date: Mon, 12 Aug 2024 11:19:03 +0200 Subject: [PATCH 5/5] refactor: make mark as watched consistent with other app elements --- src/components/VideoItem.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/VideoItem.vue b/src/components/VideoItem.vue index 474030a3..7b8a8960 100644 --- a/src/components/VideoItem.vue +++ b/src/components/VideoItem.vue @@ -127,7 +127,11 @@ ref="watchButton" @click="toggleWatched(item.url.substr(-11))" > - +