Add support for client-side watch history. (#370)

* Add support for client-side watch history.

* Update watched videos more often.
This commit is contained in:
Kavin
2021-08-22 15:57:09 +05:30
committed by GitHub
parent 6688fafeaa
commit 8feb4fbc41
13 changed files with 193 additions and 23 deletions

View File

@@ -41,6 +41,23 @@ export default {
default:
break;
}
if (this.getPreferenceBoolean("watchHistory", false))
if ("indexedDB" in window) {
const request = indexedDB.open("piped-db", 1);
request.onupgradeneeded = function() {
const db = request.result;
console.log("Upgrading object store.");
if (!db.objectStoreNames.contains("watch_history")) {
const store = db.createObjectStore("watch_history", { keyPath: "videoId" });
store.createIndex("video_id_idx", "videoId", { unique: true });
store.createIndex("id_idx", "id", { unique: true, autoIncrement: true });
}
};
request.onsuccess = e => {
window.db = e.target.result;
};
} else console.log("This browser doesn't support IndexedDB");
},
};
</script>