diff --git a/src/routes/Preferences.vue b/src/routes/Preferences.vue index 0ddb99d..a134976 100644 --- a/src/routes/Preferences.vue +++ b/src/routes/Preferences.vue @@ -202,6 +202,11 @@ export default { type: 'bool', default: true }, + { + id: 'disableDuplicateHistoryEntries', + type: 'bool', + default: false + }, { id: 'selectedSkip', type: 'select', diff --git a/src/routes/WatchVideo.vue b/src/routes/WatchVideo.vue index b08993e..409879a 100644 --- a/src/routes/WatchVideo.vue +++ b/src/routes/WatchVideo.vue @@ -148,7 +148,7 @@ import { debounce } from 'lodash-es' import { mdiThumbUp, mdiShareVariant, mdiLinkPlus } from '@mdi/js' -import { addWatchedVideo, updateWatchedVideoProgress, findLastWatch } from '@/store/watched-videos-db' +import { PMDB, addWatchedVideo, updateWatchedVideoProgress, findLastWatch } from '@/store/watched-videos-db' import { LibPiped } from '@/tools/libpiped' import Player from '@/components/Player.vue' @@ -363,12 +363,6 @@ export default { }, async getVideoData () { - try { - this.lastWatch = await findLastWatch(this.videoId) - } catch (e) { - console.error('Errored while finding last watched', e) - } - const video = await this.fetchVideo() video.videoId = this.videoId video.url = this.$route.fullPath @@ -386,7 +380,25 @@ export default { .replaceAll('https://www.youtube.com', '') .replaceAll('\n', '
') ) - this.dbID = await addWatchedVideo(video) + try { + if (!this.$store.getters['prefs/getPreference']('disableDuplicateHistoryEntries', false)) { + this.dbID = await addWatchedVideo(video) + this.lastWatch = await findLastWatch(this.videoId) + } else { + const dbObj = await findLastWatch(this.videoId) + const ts = new Date() + await PMDB.watchedVideos.update(dbObj.id, { + timestamp: ts, + video: this.video + }) + dbObj.timestamp = ts + dbObj.video = this.video + this.lastWatch = dbObj + this.dbID = dbObj.id + } + } catch (e) { + console.error('Errored while finding last watched', e) + } }, onTimeUpdate: debounce(function onTimeUpdate (e) { diff --git a/src/store/prefs-store.js b/src/store/prefs-store.js index 69fd5ed..05ed8e1 100644 --- a/src/store/prefs-store.js +++ b/src/store/prefs-store.js @@ -20,6 +20,7 @@ const PrefsStore = { sponsorblock: true, skipToLastPoint: true, clickbaitThumbnailAvoidance: false, + disableDuplicateHistoryEntries: false, disableCommentsByDefault: false, showRelatedVideos: true, diff --git a/src/store/watched-videos-db.js b/src/store/watched-videos-db.js index 0233fa8..7362970 100644 --- a/src/store/watched-videos-db.js +++ b/src/store/watched-videos-db.js @@ -24,7 +24,7 @@ export function updateWatchedVideoProgress (videoID, prog, dur) { } export async function findLastWatch (videoId) { - const v = await PMDB.watchedVideos.where('videoId').equals(videoId).reverse().sortBy('progressPcnt').limit(1) + const v = await PMDB.watchedVideos.where('videoId').equals(videoId).reverse().sortBy('progressPcnt') return v[0] } diff --git a/src/translations/bn-IN.json b/src/translations/bn-IN.json index 8d4ff43..7966ede 100644 --- a/src/translations/bn-IN.json +++ b/src/translations/bn-IN.json @@ -121,6 +121,7 @@ "showMarkers": "আপনি কি বিজ্ঞাপনের (ও অন্য বিভ্রান্তিকর জিনিসের) চিহ্নিতকারী দেখতে চান?", "bufferGoal": "কত সেকেন্ড এর data এনে রাখব যাতে আপানাকে অপেক্ষা না করতে হয়?", "disableCommentsByDefault": "মন্তব্য দেখানোর জন্য আপনার অনুমতি কি চাওয়া উচিত?", + "disableDuplicateHistoryEntries": "আপনি যদি একটা video অতীতে দেখে থাকেন তাহলে কি আর ইতিহাস এ অনুলিপি যোগ করব না, শুধু মাত্র কতটা আর কখন দেখেছেন সেটা নবীকরণ করব?", "quality_opts": { "auto": "আপনার অন্তর্জালের গতি অনুযায়ী", "144p": "১৪৪ বিন্দু আরোহ", diff --git a/src/translations/en.json b/src/translations/en.json index d292c42..ce8828f 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -141,6 +141,7 @@ "disableCommentsByDefault": "Don't show comments by default", "showRelatedVideos": "Show Related Videos", "showMarkers": "Show SponsorBlock Markers", + "disableDuplicateHistoryEntries": "Disable creation of duplicate watch history entries", "quality_opts": { "auto": "Automatically determined", "144p": "144p",