mirror of
https://github.com/TeamPiped/Piped.git
synced 2025-12-13 11:38:17 +00:00
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:
@@ -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();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user