From 4ce4a073cd2aea62e8a8d2ed5b70a1171df98eb1 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Wed, 25 Oct 2023 12:34:30 +0200 Subject: [PATCH 1/2] fix: duplicated file search request --- .../bugfix-duplicated-file-search-request | 6 +++++ .../src/components/Search/List.vue | 25 ++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 changelog/unreleased/bugfix-duplicated-file-search-request diff --git a/changelog/unreleased/bugfix-duplicated-file-search-request b/changelog/unreleased/bugfix-duplicated-file-search-request new file mode 100644 index 00000000000..60f013cf84d --- /dev/null +++ b/changelog/unreleased/bugfix-duplicated-file-search-request @@ -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 diff --git a/packages/web-app-files/src/components/Search/List.vue b/packages/web-app-files/src/components/Search/List.vue index ec489f80daa..e0b28e72832 100644 --- a/packages/web-app-files/src/components/Search/List.vue +++ b/packages/web-app-files/src/components/Search/List.vue @@ -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 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', 'q_lastModified', 'useScope'].every( + (key) => newVal[key] === oldVal[key] + ) + if (isSameTerm && isSameFilter) { + return + } + } + + emit('search', buildSearchTerm(true)) }, { deep: true } ) From feddde71553e23e2064096d75cbf5161871398d6 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Wed, 25 Oct 2023 13:28:12 +0200 Subject: [PATCH 2/2] fix: variable naming --- packages/web-app-files/src/components/Search/List.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/web-app-files/src/components/Search/List.vue b/packages/web-app-files/src/components/Search/List.vue index e0b28e72832..ad3125e8072 100644 --- a/packages/web-app-files/src/components/Search/List.vue +++ b/packages/web-app-files/src/components/Search/List.vue @@ -353,8 +353,8 @@ export default defineComponent({ (newVal, oldVal) => { // return early if this view is not active, no search needed { - const isSearchViewPainted = isLocationCommonActive(router, 'files-common-search') - if (!isSearchViewPainted) { + const isSearchViewActive = isLocationCommonActive(router, 'files-common-search') + if (!isSearchViewActive) { return } }