Skip to content

Commit

Permalink
IV: Fix search cache issues when fetching more (#3486)
Browse files Browse the repository at this point in the history
* Fix IV search cache issues

* Add comment

Co-authored-by: PikachuEXE <pikachuexe@gmail.com>

* add apiUsed

---------

Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
  • Loading branch information
ChunkyProgrammer and PikachuEXE authored May 13, 2023
1 parent a044b77 commit ff19c23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/renderer/store/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
14 changes: 9 additions & 5 deletions src/renderer/views/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ff19c23

Please sign in to comment.