Skip to content

Commit

Permalink
fix: duplicated file search request
Browse files Browse the repository at this point in the history
  • Loading branch information
fschade committed Oct 25, 2023
1 parent 4949e29 commit 8620af5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-duplicated-file-search-request
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Duplicated file search request

We have fixed a bug where the search was sent unnecessarily twice.

https://github.com/owncloud/web/pull/9861
https://github.com/owncloud/web/issues/9787
25 changes: 19 additions & 6 deletions packages/web-app-files/src/components/Search/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,26 @@ export default defineComponent({
watch(
() => unref(route).query,
(newVal, oldVal) => {
const filters = ['q_fullText', 'q_tags', 'useScope']
const isChange =
newVal?.term !== oldVal?.term ||
filters.some((f) => newVal[f] ?? undefined !== oldVal[f] ?? undefined)
if (isChange && isLocationCommonActive(router, 'files-common-search')) {
emit('search', buildSearchTerm(true))
// return early if this view is not active, no search needed
{
const isSearchViewPainted = isLocationCommonActive(router, 'files-common-search')
if (!isSearchViewPainted) {
return
}
}
// return early if the search term or filter has not changed, no search needed
{
const isSameTerm = newVal?.term === oldVal?.term
const isSameFilter = ['q_fullText', 'q_tags', 'useScope'].every(
(key) => newVal[key] === oldVal[key]
)
if (isSameTerm && isSameFilter) {
return
}
}
emit('search', buildSearchTerm(true))
},
{ deep: true }
)
Expand Down

0 comments on commit 8620af5

Please sign in to comment.