Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: duplicated file search request #9861

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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