Skip to content

Commit

Permalink
Fix duplicate content updates run on channel switch (FreeTubeApp#3764)
Browse files Browse the repository at this point in the history
* Revert "Bump prettier from 2.8.8 to 3.0.0 (FreeTubeApp#3758)"

This reverts commit f77ae6d.

* ! Fix duplicate content updates run on channel switch
  • Loading branch information
PikachuEXE authored Jul 13, 2023
1 parent 0d10fac commit 930184d
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/renderer/views/Channel/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export default defineComponent({
playlistSelectValues: [
'newest',
'last'
]
],

autoRefreshOnSortByChangeEnabled: false,
}
},
computed: {
Expand Down Expand Up @@ -257,6 +259,9 @@ export default defineComponent({
return
}

// Disable auto refresh on sort value change during state reset
this.autoRefreshOnSortByChangeEnabled = false

this.id = this.$route.params.id
this.searchPage = 2
this.relatedChannels = []
Expand Down Expand Up @@ -296,14 +301,20 @@ export default defineComponent({
this.showShareMenu = true
this.errorMessage = ''

// Re-enable auto refresh on sort value change AFTER update done
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
this.getChannelInfoInvidious()
this.autoRefreshOnSortByChangeEnabled = true
} else {
this.getChannelLocal()
this.getChannelLocal().finally(() => {
this.autoRefreshOnSortByChangeEnabled = true
})
}
},

videoSortBy () {
if (!this.autoRefreshOnSortByChangeEnabled) { return }

this.isElementListLoading = true
this.latestVideos = []
switch (this.apiUsed) {
Expand All @@ -319,6 +330,8 @@ export default defineComponent({
},

shortSortBy() {
if (!this.autoRefreshOnSortByChangeEnabled) { return }

this.isElementListLoading = true
this.latestShorts = []
switch (this.apiUsed) {
Expand All @@ -334,6 +347,8 @@ export default defineComponent({
},

liveSortBy () {
if (!this.autoRefreshOnSortByChangeEnabled) { return }

this.isElementListLoading = true
this.latestLive = []
switch (this.apiUsed) {
Expand All @@ -349,6 +364,8 @@ export default defineComponent({
},

playlistSortBy () {
if (!this.autoRefreshOnSortByChangeEnabled) { return }

this.isElementListLoading = true
this.latestPlaylists = []
this.playlistContinuationData = null
Expand Down Expand Up @@ -382,10 +399,14 @@ export default defineComponent({
return
}

// Enable auto refresh on sort value change AFTER initial update done
if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') {
this.getChannelInfoInvidious()
this.autoRefreshOnSortByChangeEnabled = true
} else {
this.getChannelLocal()
this.getChannelLocal().finally(() => {
this.autoRefreshOnSortByChangeEnabled = true
})
}
},
methods: {
Expand Down

0 comments on commit 930184d

Please sign in to comment.