From ff19c233c14f6ed8f087280730626cb85979c2d8 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Sat, 13 May 2023 07:18:49 -0400 Subject: [PATCH] IV: Fix search cache issues when fetching more (#3486) * Fix IV search cache issues * Add comment Co-authored-by: PikachuEXE * add apiUsed --------- Co-authored-by: PikachuEXE --- src/renderer/store/modules/utils.js | 8 +++++++- src/renderer/views/Search/Search.js | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index 0dd00f957..217bc4c73 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -612,7 +612,13 @@ const mutations = { if (sameSearch !== -1) { state.sessionSearchHistory[sameSearch].data = payload.data - state.sessionSearchHistory[sameSearch].nextPageRef = payload.nextPageRef + if (payload.nextPageRef) { + // Local API + state.sessionSearchHistory[sameSearch].nextPageRef = payload.nextPageRef + } else if (payload.searchPage) { + // Invidious API + state.sessionSearchHistory[sameSearch].searchPage = payload.searchPage + } } else { state.sessionSearchHistory.push(payload) } diff --git a/src/renderer/views/Search/Search.js b/src/renderer/views/Search/Search.js index 9a31d8bdc..62f2b1bd0 100644 --- a/src/renderer/views/Search/Search.js +++ b/src/renderer/views/Search/Search.js @@ -91,7 +91,6 @@ export default defineComponent({ if (sameSearch.length > 0) { // No loading effect needed here, only rendered result update - this.replaceShownResults(sameSearch[0]) } else { // Show loading effect coz there will be network request(s) @@ -130,7 +129,8 @@ export default defineComponent({ query: payload.query, data: this.shownResults, searchSettings: this.searchSettings, - nextPageRef: this.nextPageRef + nextPageRef: this.nextPageRef, + apiUsed: this.apiUsed } this.$store.commit('addToSessionSearchHistory', historyPayload) @@ -166,7 +166,8 @@ export default defineComponent({ query: payload.query, data: this.shownResults, searchSettings: this.searchSettings, - nextPageRef: this.nextPageRef + nextPageRef: this.nextPageRef, + apiUsed: this.apiUsed } this.$store.commit('addToSessionSearchHistory', historyPayload) @@ -223,14 +224,16 @@ export default defineComponent({ this.shownResults = returnData } - this.searchPage++ this.isLoading = false + this.searchPage++ + const historyPayload = { query: payload.query, data: this.shownResults, searchSettings: this.searchSettings, - searchPage: this.searchPage + searchPage: this.searchPage, + apiUsed: this.apiUsed } this.$store.commit('addToSessionSearchHistory', historyPayload) @@ -277,6 +280,7 @@ export default defineComponent({ this.shownResults = history.data this.searchSettings = history.searchSettings this.amountOfResults = history.amountOfResults + this.apiUsed = history.apiUsed if (typeof (history.nextPageRef) !== 'undefined') { this.nextPageRef = history.nextPageRef