Skip to content

Commit

Permalink
Merge pull request #9861 from owncloud/fix-duplicated-search-request
Browse files Browse the repository at this point in the history
fix: duplicated file search request
  • Loading branch information
JammingBen authored Oct 26, 2023
2 parents c9fac84 + feddde7 commit ce03415
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 @@ -351,13 +351,26 @@ export default defineComponent({
watch(
() => unref(route).query,
(newVal, oldVal) => {
const filters = ['q_fullText', 'q_tags', 'q_lastModified', '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 isSearchViewActive = isLocationCommonActive(router, 'files-common-search')
if (!isSearchViewActive) {
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', 'q_lastModified', 'useScope'].every(
(key) => newVal[key] === oldVal[key]
)
if (isSameTerm && isSameFilter) {
return
}
}
emit('search', buildSearchTerm(true))
},
{ deep: true }
)
Expand Down

0 comments on commit ce03415

Please sign in to comment.