mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
wait to save video ts until saved video ts is loaded (#726)
This commit introduces a new member to VideoPlayer, initialSeekComplete. The boolean is set to true after the timestamp has been set on videoEl from the query or IDB. If there's no existing timestamp its set to true immediately. Change updateProgressDatabase() to update watch_history when initialSeekComplete is true. This fixes a race condition where updateProgressDatabase() would run before the saved time could be loaded. Since the initial timestamp on the video element was 0 the saved time would be forgotten.
This commit is contained in:
parent
f0378f3e82
commit
90cf70cc31
1 changed files with 9 additions and 1 deletions
|
@ -40,6 +40,7 @@ export default {
|
||||||
$player: null,
|
$player: null,
|
||||||
$ui: null,
|
$ui: null,
|
||||||
lastUpdate: new Date().getTime(),
|
lastUpdate: new Date().getTime(),
|
||||||
|
initialSeekComplete: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -206,6 +207,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
videoEl.currentTime = start;
|
videoEl.currentTime = start;
|
||||||
|
this.initialSeekComplete = true;
|
||||||
} else if (window.db) {
|
} else if (window.db) {
|
||||||
var tx = window.db.transaction("watch_history", "readonly");
|
var tx = window.db.transaction("watch_history", "readonly");
|
||||||
var store = tx.objectStore("watch_history");
|
var store = tx.objectStore("watch_history");
|
||||||
|
@ -216,6 +218,12 @@ export default {
|
||||||
videoEl.currentTime = video.currentTime;
|
videoEl.currentTime = video.currentTime;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tx.oncomplete = () => {
|
||||||
|
this.initialSeekComplete = true;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.initialSeekComplete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const noPrevPlayer = !this.$player;
|
const noPrevPlayer = !this.$player;
|
||||||
|
@ -489,7 +497,7 @@ export default {
|
||||||
if (new Date().getTime() - this.lastUpdate < 500) return;
|
if (new Date().getTime() - this.lastUpdate < 500) return;
|
||||||
this.lastUpdate = new Date().getTime();
|
this.lastUpdate = new Date().getTime();
|
||||||
|
|
||||||
if (!this.video.id || !window.db) return;
|
if (!this.initialSeekComplete || !this.video.id || !window.db) return;
|
||||||
|
|
||||||
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");
|
||||||
|
|
Loading…
Reference in a new issue