From 0ff898c927bfb7c639746da4d1b584cb0756ef4b Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Aug 2022 23:21:27 +0530 Subject: [PATCH] Return the most watched item in the database This fixes a issue where a more recent watch event that was shorter than a existing watch confused users into thinking that the video wasn't completely watched already. --- src/store/watched-videos-db.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/store/watched-videos-db.js b/src/store/watched-videos-db.js index 1b432ec..708ed22 100644 --- a/src/store/watched-videos-db.js +++ b/src/store/watched-videos-db.js @@ -23,8 +23,9 @@ export function updateWatchedVideoProgress (videoID, prog, dur) { }) } -export function findLastWatch (videoId) { - return PMDB.watchedVideos.where('videoId').equals(videoId).last() +export async function findLastWatch (videoId) { + const v = await PMDB.watchedVideos.where('videoId').equals(videoId).reverse().sortBy('progressPcnt') + return v[0] } export function getWatchedVideos () {