diff --git a/src/components/FeedPage.vue b/src/components/FeedPage.vue
index 882196a6..e6e5e4b8 100644
--- a/src/components/FeedPage.vue
+++ b/src/components/FeedPage.vue
@@ -18,7 +18,13 @@
-
+
@@ -85,6 +91,9 @@ export default {
this.loadMoreVideos();
}
},
+ onUpdateWatched() {
+ if (this.videos.length > 0) this.updateWatched(this.videos);
+ },
},
};
diff --git a/src/components/VideoItem.vue b/src/components/VideoItem.vue
index 136edfb3..ed4e5383 100644
--- a/src/components/VideoItem.vue
+++ b/src/components/VideoItem.vue
@@ -74,11 +74,16 @@
@@ -148,6 +153,7 @@ export default {
playlistId: { type: String, default: null },
admin: { type: Boolean, default: false },
},
+ emits: ["update:watched"],
data() {
return {
showModal: false,
@@ -190,13 +196,22 @@ export default {
}
};
},
- markAsWatched(videoId) {
+ toggleWatched(videoId) {
if (window.db) {
// Should match WatchVideo.vue
var tx = window.db.transaction("watch_history", "readwrite");
var store = tx.objectStore("watch_history");
- var request = store.get(videoId);
var instance = this;
+
+ if (this.video.watched) {
+ let request = store.delete(videoId);
+ request.onsuccess = function () {
+ instance.$emit("update:watched");
+ };
+ return;
+ }
+
+ var request = store.get(videoId);
request.onsuccess = function (event) {
var video = event.target.result;
if (video) {
@@ -217,7 +232,8 @@ export default {
video.currentTime = instance.video.duration;
// Save
store.put(video);
- // Disappear
+ // Disappear if hideWatched is on
+ instance.$emit("update:watched");
instance.shouldShowVideo();
};
}
diff --git a/src/main.js b/src/main.js
index 9ea9cf48..c938a472 100644
--- a/src/main.js
+++ b/src/main.js
@@ -2,6 +2,7 @@ import { createApp } from "vue";
import { library } from "@fortawesome/fontawesome-svg-core";
import {
faEye,
+ faEyeSlash,
faThumbtack,
faCheck,
faHeart,
@@ -25,6 +26,7 @@ import { faGithub, faBitcoin } from "@fortawesome/free-brands-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
library.add(
faEye,
+ faEyeSlash,
faGithub,
faBitcoin,
faThumbtack,
@@ -197,9 +199,7 @@ const mixin = {
videos.map(async video => {
var request = store.get(video.url.substr(-11));
request.onsuccess = function (event) {
- if (event.target.result) {
- video.watched = true;
- }
+ video.watched = Boolean(event.target.result);
};
});
}