Add router caching. (#248)

* Add router caching.

* Avoid memory leak by limiting cache size.

* Fix search result caching.

* Remove remains of previous player.

Fixes an issue where the spinner/loading from a previous player can show up in a cached page.
This commit is contained in:
FireMasterK
2021-07-07 19:48:09 +05:30
committed by GitHub
parent 9345e1a917
commit b0d9145e75
6 changed files with 36 additions and 21 deletions

View File

@@ -134,21 +134,23 @@ export default {
};
},
mounted() {
this.selectedAutoPlay = this.getPreferenceBoolean("autoplay", true);
this.getVideoData();
this.getVideoData().then(() => {
this.$refs.videoPlayer.loadVideo();
});
this.getSponsors();
this.getComments();
},
activated() {
this.selectedAutoPlay = this.getPreferenceBoolean("autoplay", true);
if (this.video.duration) this.$refs.videoPlayer.loadVideo();
window.addEventListener("scroll", this.handleScroll);
},
unmounted() {
deactivated() {
window.removeEventListener("scroll", this.handleScroll);
},
watch: {
"$route.query.v": function(v) {
if (v) {
this.getVideoData();
this.getSponsors();
this.getComments();
window.scrollTo(0, 0);
}
},
@@ -175,7 +177,7 @@ export default {
this.setPreference("autoplay", this.selectedAutoPlay);
},
async getVideoData() {
this.fetchVideo()
await this.fetchVideo()
.then(data => {
this.video = data;
})
@@ -189,8 +191,6 @@ export default {
.replaceAll("https://www.youtube.com", "")
.replaceAll("\n", "<br>"),
);
this.$refs.videoPlayer.loadVideo();
}
});
},