Add an option to disable duplicate history entries

This commit is contained in:
root
2023-05-24 02:06:26 +05:30
parent d473b95c6d
commit f2b7d90dd2
6 changed files with 29 additions and 9 deletions
+5
View File
@@ -202,6 +202,11 @@ export default {
type: 'bool',
default: true
},
{
id: 'disableDuplicateHistoryEntries',
type: 'bool',
default: false
},
{
id: 'selectedSkip',
type: 'select',
+20 -8
View File
@@ -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', '<br>')
)
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) {
+1
View File
@@ -20,6 +20,7 @@ const PrefsStore = {
sponsorblock: true,
skipToLastPoint: true,
clickbaitThumbnailAvoidance: false,
disableDuplicateHistoryEntries: false,
disableCommentsByDefault: false,
showRelatedVideos: true,
+1 -1
View File
@@ -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]
}
+1
View File
@@ -121,6 +121,7 @@
"showMarkers": "আপনি কি বিজ্ঞাপনের (ও অন্য বিভ্রান্তিকর জিনিসের) চিহ্নিতকারী দেখতে চান?",
"bufferGoal": "কত সেকেন্ড এর data এনে রাখব যাতে আপানাকে অপেক্ষা না করতে হয়?",
"disableCommentsByDefault": "মন্তব্য দেখানোর জন্য আপনার অনুমতি কি চাওয়া উচিত?",
"disableDuplicateHistoryEntries": "আপনি যদি একটা video অতীতে দেখে থাকেন তাহলে কি আর ইতিহাস এ অনুলিপি যোগ করব না, শুধু মাত্র কতটা আর কখন দেখেছেন সেটা নবীকরণ করব?",
"quality_opts": {
"auto": "আপনার অন্তর্জালের গতি অনুযায়ী",
"144p": "১৪৪ বিন্দু আরোহ",
+1
View File
@@ -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",