]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix loading error catch
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Tue, 15 Sep 2020 13:01:50 +0000 (15:01 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 18 Sep 2020 09:36:39 +0000 (09:36 +0000)
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
core/src/logger.js
core/src/login.js
core/src/maintenance.js
core/src/recommendedapps.js
core/src/session-heartbeat.js
core/src/unified-search.js
core/src/views/UnifiedSearch.vue

index 4a9c8623a7f815d83720c868c728d032361f0aff..bd01f58a4135866297df58b15a0410298c000e73 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
  *
  * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
index bfcfabf169f3f098ab6d39aed11fb715dba06144..a7d738ee9ef3fdd529eb9d841331ce7d0928ca1a 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
  *
  * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
index de4315d32a24fa391f5774eee2979f334e3c0f8d..3abc20ea8fc5434fbb82c644fda535530b581a0a 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
  *
  * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
index aea105a84222b2e2211ad141f4dc47fd4a200ae9..ef9071eb42c8fcb7dcfd67710d9ac8f3f8dc4006 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
  *
  * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
index aab30c2c4cbcb7da4763955a86ff71b82381c2b6..9902bef882a2bb241032fd76f211463fb532e17f 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
  *
  * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
index ba975d78564b6922539d82f6a0952af64f76c832..0d97738358634869c8fd6029b52ae04874fd8353 100644 (file)
@@ -19,8 +19,9 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-import { getRequestToken } from '@nextcloud/auth'
 import { generateFilePath } from '@nextcloud/router'
+import { getLoggerBuilder } from '@nextcloud/logger'
+import { getRequestToken } from '@nextcloud/auth'
 import { translate as t, translatePlural as n } from '@nextcloud/l10n'
 import Vue from 'vue'
 
@@ -32,7 +33,17 @@ __webpack_nonce__ = btoa(getRequestToken())
 // eslint-disable-next-line camelcase
 __webpack_public_path__ = generateFilePath('core', '', 'js/')
 
+const logger = getLoggerBuilder()
+       .setApp('unified-search')
+       .detectUser()
+       .build()
+
 Vue.mixin({
+       data() {
+               return {
+                       logger,
+               }
+       },
        methods: {
                t,
                n,
index c721689537bb45b87e04ef6e013b33de976128a0..b68051de90d63ddfa2f1749a793249d2bdf943cd 100644 (file)
@@ -57,7 +57,7 @@
                        <!-- Loading placeholders -->
                        <SearchResultPlaceholders v-if="isLoading" />
 
-                       <EmptyContent v-else-if="isValidQuery && isDoneSearching" icon="icon-search">
+                       <EmptyContent v-else-if="isValidQuery" icon="icon-search">
                                {{ t('core', 'No results for {query}', {query}) }}
                        </EmptyContent>
 
@@ -116,6 +116,7 @@ import Magnify from 'vue-material-design-icons/Magnify'
 import HeaderMenu from '../components/HeaderMenu'
 import SearchResult from '../components/UnifiedSearch/SearchResult'
 import SearchResultPlaceholders from '../components/UnifiedSearch/SearchResultPlaceholders'
+import { showError } from '@nextcloud/dialogs'
 
 export default {
        name: 'UnifiedSearch',
@@ -255,7 +256,7 @@ export default {
 
        async created() {
                this.types = await getTypes()
-               console.debug('Unified Search initialized with the following providers', this.types)
+               this.logger.debug('Unified Search initialized with the following providers', this.types)
        },
 
        mounted() {
@@ -372,42 +373,49 @@ export default {
                        // Remove any filters from the query
                        query = query.replace(regexFilterIn, '').replace(regexFilterNot, '')
 
-                       console.debug('Searching', query, 'in', types)
+                       this.logger.debug(`Searching ${query} in`, types)
 
                        // Reset search if the query changed
                        this.resetState()
 
                        types.forEach(async type => {
-                               this.$set(this.loading, type, true)
-                               const request = await search(type, query)
+                               try {
+                                       this.$set(this.loading, type, true)
+                                       const request = await search(type, query)
+
+                                       // Process results
+                                       if (request.data.ocs.data.entries.length > 0) {
+                                               this.$set(this.results, type, request.data.ocs.data.entries)
+                                       } else {
+                                               this.$delete(this.results, type)
+                                       }
+
+                                       // Save cursor if any
+                                       if (request.data.ocs.data.cursor) {
+                                               this.$set(this.cursors, type, request.data.ocs.data.cursor)
+                                       } else if (!request.data.ocs.data.isPaginated) {
+                                               // If no cursor and no pagination, we save the default amount
+                                               // provided by server's initial state `defaultLimit`
+                                               this.$set(this.limits, type, this.defaultLimit)
+                                       }
+
+                                       // Check if we reached end of pagination
+                                       if (request.data.ocs.data.entries.length < this.defaultLimit) {
+                                               this.$set(this.reached, type, true)
+                                       }
+
+                                       // If none already focused, focus the first rendered result
+                                       if (this.focused === null) {
+                                               this.focused = 0
+                                       }
+                               } catch (error) {
+                                       this.logger.error(`Error searching for ${this.typesMap[type]}`, error)
+                                       showError(this.t('core', 'An error occurred while looking for {type}', { type: this.typesMap[type] }))
 
-                               // Process results
-                               if (request.data.ocs.data.entries.length > 0) {
-                                       this.$set(this.results, type, request.data.ocs.data.entries)
-                               } else {
                                        this.$delete(this.results, type)
+                               } finally {
+                                       this.$set(this.loading, type, false)
                                }
-
-                               // Save cursor if any
-                               if (request.data.ocs.data.cursor) {
-                                       this.$set(this.cursors, type, request.data.ocs.data.cursor)
-                               } else if (!request.data.ocs.data.isPaginated) {
-                                       // If no cursor and no pagination, we save the default amount
-                                       // provided by server's initial state `defaultLimit`
-                                       this.$set(this.limits, type, this.defaultLimit)
-                               }
-
-                               // Check if we reached end of pagination
-                               if (request.data.ocs.data.entries.length < this.defaultLimit) {
-                                       this.$set(this.reached, type, true)
-                               }
-
-                               // If none already focused, focus the first rendered result
-                               if (this.focused === null) {
-                                       this.focused = 0
-                               }
-
-                               this.$set(this.loading, type, false)
                        })
                },
                onInputDebounced: debounce(function(e) {