mirror of
https://github.com/TeamPiped/Piped.git
synced 2026-06-02 04:44:30 +00:00
Merge pull request #4245 from t6fb3m59/upstream-pr
Fix position saving for videos and have history update when opened
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onActivated, onDeactivated } from "vue";
|
||||
import { ref, onActivated, onDeactivated } from "vue";
|
||||
import VideoItem from "./VideoItem.vue";
|
||||
import SortingSelector from "./SortingSelector.vue";
|
||||
import ExportHistoryModal from "./ExportHistoryModal.vue";
|
||||
@@ -73,8 +73,8 @@ let currentVideoCount = 0;
|
||||
const videoStep = 100;
|
||||
const videosStore = [];
|
||||
const videos = ref([]);
|
||||
const autoDeleteHistory = ref(false);
|
||||
const autoDeleteDelayHours = ref("24");
|
||||
const autoDeleteHistory = ref(getPreferenceBoolean("autoDeleteWatchHistory", false));
|
||||
const autoDeleteDelayHours = ref(getPreferenceString("autoDeleteWatchHistoryDelayHours", "24"));
|
||||
const showExportModal = ref(false);
|
||||
const showImportModal = ref(false);
|
||||
|
||||
@@ -109,11 +109,12 @@ function onChange() {
|
||||
setPreference("autoDeleteWatchHistoryDelayHours", autoDeleteDelayHours.value);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
autoDeleteHistory.value = getPreferenceBoolean("autoDeleteWatchHistory", false);
|
||||
autoDeleteDelayHours.value = getPreferenceString("autoDeleteWatchHistoryDelayHours", "24");
|
||||
function loadHistory() {
|
||||
videosStore.length = 0;
|
||||
currentVideoCount = 0;
|
||||
videos.value = [];
|
||||
|
||||
(async () => {
|
||||
return (async () => {
|
||||
if (window.db && getPreferenceBoolean("watchHistory", false)) {
|
||||
var tx = window.db.transaction("watch_history", "readwrite");
|
||||
var store = tx.objectStore("watch_history");
|
||||
@@ -148,10 +149,11 @@ onMounted(() => {
|
||||
})().then(() => {
|
||||
loadMoreVideos();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onActivated(() => {
|
||||
document.title = "Watch History - Piped";
|
||||
loadHistory();
|
||||
window.addEventListener("scroll", handleScroll);
|
||||
});
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ async function updateProgressDatabase(time) {
|
||||
if (new Date().getTime() - lastUpdate.value < 500) return;
|
||||
lastUpdate.value = new Date().getTime();
|
||||
|
||||
if (!initialSeekComplete.value || !props.video.id || !window.db) return;
|
||||
if (!initialSeekComplete.value || destroying.value || !props.video.id || !window.db) return;
|
||||
|
||||
var tx = window.db.transaction("watch_history", "readwrite");
|
||||
var store = tx.objectStore("watch_history");
|
||||
@@ -448,7 +448,6 @@ async function setPlayerAttrs(localPlayer, el, uri, mime, shaka) {
|
||||
|
||||
if (time) {
|
||||
startTime = parseTimeParam(time);
|
||||
initialSeekComplete.value = true;
|
||||
} else if (window.db && getPreferenceBoolean("watchHistory", false)) {
|
||||
await new Promise(resolve => {
|
||||
var tx = window.db.transaction("watch_history", "readonly");
|
||||
@@ -464,18 +463,19 @@ async function setPlayerAttrs(localPlayer, el, uri, mime, shaka) {
|
||||
}
|
||||
resolve();
|
||||
};
|
||||
|
||||
tx.oncomplete = () => {
|
||||
initialSeekComplete.value = true;
|
||||
};
|
||||
});
|
||||
} else {
|
||||
initialSeekComplete.value = true;
|
||||
}
|
||||
|
||||
playerInstance
|
||||
.load(uri, startTime, mime)
|
||||
.load(uri, null, mime)
|
||||
.then(async () => {
|
||||
// Player.load()'s startTime arg does not reliably perform the
|
||||
// initial seek; apply it here. See shaka-project/shaka-player#6241.
|
||||
if (startTime > 0) {
|
||||
el.currentTime = startTime;
|
||||
await new Promise(resolve => el.addEventListener("seeked", resolve, { once: true }));
|
||||
}
|
||||
initialSeekComplete.value = true;
|
||||
let lang = "en";
|
||||
const prefLang = getPreferenceString("hl", "en").substr(0, 2);
|
||||
const audioTracks = playerInstance.getAudioTracks();
|
||||
@@ -573,6 +573,8 @@ async function setPlayerAttrs(localPlayer, el, uri, mime, shaka) {
|
||||
}
|
||||
|
||||
async function loadVideo() {
|
||||
initialSeekComplete.value = false;
|
||||
|
||||
updateSponsors();
|
||||
|
||||
const el = videoEl.value;
|
||||
|
||||
Reference in New Issue
Block a user