Change toggle to markAsWatched only.

This commit is contained in:
Chris Hallberg 2022-10-17 21:58:50 -04:00
parent 1d1d9d583e
commit 4d827baf3b

View file

@ -75,7 +75,7 @@
</button> </button>
<button <button
v-if="isFeed && this.getPreferenceBoolean('hideWatched', false)" v-if="isFeed && this.getPreferenceBoolean('hideWatched', false)"
@click="toggleWatched(video.url.substr(-11))" @click="markAsWatched(video.url.substr(-11))"
ref="watchButton" ref="watchButton"
> >
<font-awesome-icon icon="eye" :title="$t('actions.mark_as_watched')" /> <font-awesome-icon icon="eye" :title="$t('actions.mark_as_watched')" />
@ -194,9 +194,9 @@ export default {
} }
}; };
}, },
toggleWatched(videoId) { markAsWatched(videoId) {
// Copied from WatchVideo.vue
if (window.db) { if (window.db) {
// Should match WatchVideo.vue
var tx = window.db.transaction("watch_history", "readwrite"); var tx = window.db.transaction("watch_history", "readwrite");
var store = tx.objectStore("watch_history"); var store = tx.objectStore("watch_history");
var request = store.get(videoId); var request = store.get(videoId);
@ -204,11 +204,7 @@ export default {
request.onsuccess = function (event) { request.onsuccess = function (event) {
var video = event.target.result; var video = event.target.result;
if (video) { if (video) {
if (!instance.video.watched) {
video.watchedAt = Date.now(); video.watchedAt = Date.now();
} else {
// #todo: remove
}
} else { } else {
video = { video = {
videoId: videoId, videoId: videoId,
@ -220,14 +216,12 @@ export default {
watchedAt: Date.now(), watchedAt: Date.now(),
}; };
} }
// Set time to end for shouldShowVideo
// Save to db video.currentTime = instance.video.duration;
// Save
store.put(video); store.put(video);
// Disappear
// Disappear?
if (instance.getPreferenceBoolean("hideWatched", false)) {
instance.shouldShowVideo(); instance.shouldShowVideo();
}
}; };
} }
}, },