From a9dc9c028d4cc49eededc81dafc88c1c5c79cbf4 Mon Sep 17 00:00:00 2001 From: bob1520 <80553357+hockerschwan@users.noreply.github.com> Date: Wed, 25 May 2022 18:32:19 +0900 Subject: [PATCH] Fix: wrong info displayed when quickly navigate from a channel to another (#2259) * Fix: wrong info displayed when you quickly navigate from a channel to another (Invidious) * localapi * id --- src/renderer/views/Channel/Channel.js | 28 +++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/renderer/views/Channel/Channel.js b/src/renderer/views/Channel/Channel.js index 930f7030..af451826 100644 --- a/src/renderer/views/Channel/Channel.js +++ b/src/renderer/views/Channel/Channel.js @@ -249,7 +249,12 @@ export default Vue.extend({ getChannelInfoLocal: function () { this.apiUsed = 'local' - ytch.getChannelInfo({ channelId: this.id }).then((response) => { + const expectedId = this.id + ytch.getChannelInfo({ channelId: expectedId }).then((response) => { + if (expectedId !== this.id) { + return + } + this.id = response.authorId this.channelName = response.author document.title = `${this.channelName} - ${process.env.PRODUCT_NAME}` @@ -308,7 +313,12 @@ export default Vue.extend({ getChannelVideosLocal: function () { this.isElementListLoading = true - ytch.getChannelVideos({ channelId: this.id, sortBy: this.videoSortBy }).then((response) => { + const expectedId = this.id + ytch.getChannelVideos({ channelId: expectedId, sortBy: this.videoSortBy }).then((response) => { + if (expectedId !== this.id) { + return + } + this.latestVideos = response.items this.videoContinuationString = response.continuation this.isElementListLoading = false @@ -354,7 +364,12 @@ export default Vue.extend({ this.isLoading = true this.apiUsed = 'invidious' - this.invidiousGetChannelInfo(this.id).then((response) => { + const expectedId = this.id + this.invidiousGetChannelInfo(expectedId).then((response) => { + if (expectedId !== this.id) { + return + } + console.log(response) this.channelName = response.author document.title = `${this.channelName} - ${process.env.PRODUCT_NAME}` @@ -422,7 +437,12 @@ export default Vue.extend({ }, getPlaylistsLocal: function () { - ytch.getChannelPlaylistInfo({ channelId: this.id, sortBy: this.playlistSortBy }).then((response) => { + const expectedId = this.id + ytch.getChannelPlaylistInfo({ channelId: expectedId, sortBy: this.playlistSortBy }).then((response) => { + if (expectedId !== this.id) { + return + } + console.log(response) this.latestPlaylists = response.items.map((item) => { item.proxyThumbnail = false