Use index for sorting Watch History.

This commit is contained in:
Kavin
2022-10-20 16:59:22 +01:00
parent 5bf24200b7
commit 05e78fed6e
2 changed files with 7 additions and 4 deletions

View File

@@ -39,7 +39,7 @@ export default {
if (window.db) {
var tx = window.db.transaction("watch_history", "readonly");
var store = tx.objectStore("watch_history");
const cursorRequest = store.openCursor();
const cursorRequest = store.index("watchedAt").openCursor(null, "prev");
cursorRequest.onsuccess = e => {
const cursor = e.target.result;
if (cursor) {
@@ -53,7 +53,6 @@ export default {
thumbnail: video.thumbnail,
watchedAt: video.watchedAt,
});
this.videos.sort((a, b) => b.watchedAt - a.watchedAt); // TODO: Optimize
if (this.videos.length < 1000) cursor.continue();
}
};