diff --git a/src/components/Mailbox.vue b/src/components/Mailbox.vue index ab52b9b919..eaf6d6f58c 100644 --- a/src/components/Mailbox.vue +++ b/src/components/Mailbox.vue @@ -201,17 +201,24 @@ export default { this.stopInterval() }, methods: { - initializeCache() { + async initializeCache() { + if (this.loadingCacheInitialization) { + logger.debug('Cache initialization in progress, skipping envelope fetch') + return + } this.loadingCacheInitialization = true this.error = false - logger.debug(`syncing folder ${this.mailbox.databaseId} (${this.query}) during cache initalization`) - this.sync(true) - .then(() => { - this.loadingCacheInitialization = false - - return this.loadEnvelopes() - }) + logger.debug(`syncing folder ${this.mailbox.databaseId} (${this.query}) during cache initialization`) + try { + await this.sync(true) + await this.loadEnvelopes() + } catch (error) { + logger.error(`Could not initialize cache of folder ${this.mailbox.databaseId} (${this.searchQuery})`, { error }) + this.error = error + } finally { + this.loadingCacheInitialization = false + } }, async loadEnvelopes() { logger.debug(`Fetching envelopes for folder ${this.mailbox.databaseId} (${this.searchQuery})`, this.mailbox)