Add Location Storage

This commit is contained in:
Vincent Schmandt 2023-03-21 13:34:21 +01:00
parent e018f8341e
commit 17b8cf19b7
No known key found for this signature in database
GPG Key ID: FA5B5F9C571C0669

View File

@ -107,18 +107,29 @@ export default {
height: window.innerHeight * 0.9
});
reader.rendition.display(cfi);
reader.rendition.display(this.userMediaProgress?.currentTime);
reader.book.ready.then(() => {
reader.rendition.on('relocated', reader.relocated);
reader.rendition.on('keydown', reader.keyUp)
document.addEventListener('keydown', reader.keyUp, false);
reader.book.locations.generate();
if (reader.userMediaProgress?.duration) {
reader.book.locations.load(reader.userMediaProgress.duration)
} else {
reader.book.locations.generate().then(() => {
var updatePayload = {
duration: reader.book.locations.save(),
}
this.$axios.$patch(`/api/me/progress/${this.libraryItemId}`, updatePayload).catch((error) => {
console.error('Failed', error)
})
});
}
});
},
},
mounted() {
this.initEpub(this.userMediaProgress?.currentTime);
this.initEpub();
},
};
</script>