From c90d414fdfc2e573f99f000e1e9717c5fd6a8126 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Apr 2023 15:28:43 +0200 Subject: [PATCH] fix(status): Correctly set the message and predefined message using the store Signed-off-by: Joas Schilling --- .../src/components/SetStatusModal.vue | 28 +++++++++++++------ .../user_status/src/store/userBackupStatus.js | 8 ++++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/apps/user_status/src/components/SetStatusModal.vue b/apps/user_status/src/components/SetStatusModal.vue index f4b528a5a92..0ee8b3a1e18 100644 --- a/apps/user_status/src/components/SetStatusModal.vue +++ b/apps/user_status/src/components/SetStatusModal.vue @@ -48,11 +48,11 @@ @submit="saveStatus" @select-icon="setIcon" /> -
{{ $t('user_status', 'Your status was set automatically') }}
- @@ -123,6 +123,9 @@ export default { message() { return this.$store.state.userStatus.message || '' }, + hasBackupStatus() { + return this.messageId && (this.backupIcon || this.backupMessage) + }, backupIcon() { return this.$store.state.userBackupStatus.icon || '' }, @@ -176,8 +179,11 @@ export default { * @param {string} icon The new icon */ setIcon(icon) { - this.messageId = null - this.icon = icon + this.$store.dispatch('setCustomMessage', { + message: this.message, + icon, + clearAt: this.clearAt, + }) this.$nextTick(() => { this.$refs.customMessageInput.focus() }) @@ -188,8 +194,11 @@ export default { * @param {string} message The new message */ setMessage(message) { - this.messageId = null - this.message = message + this.$store.dispatch('setCustomMessage', { + message, + icon: this.icon, + clearAt: this.clearAt, + }) }, /** * Sets a new clearAt value @@ -205,10 +214,11 @@ export default { * @param {object} status The predefined status object */ selectPredefinedMessage(status) { - this.messageId = status.id this.clearAt = status.clearAt - this.icon = status.icon - this.message = status.message + this.$store.dispatch('setPredefinedMessage', { + messageId: status.id, + clearAt: status.clearAt, + }) }, /** * Saves the status and closes the diff --git a/apps/user_status/src/store/userBackupStatus.js b/apps/user_status/src/store/userBackupStatus.js index c4258d998be..15f870112ca 100644 --- a/apps/user_status/src/store/userBackupStatus.js +++ b/apps/user_status/src/store/userBackupStatus.js @@ -94,8 +94,12 @@ const actions = { * @return {Promise} */ async fetchBackupFromServer({ commit }) { - const status = await fetchBackupStatus(getCurrentUser()?.uid) - commit('loadBackupStatusFromServer', status) + try { + const status = await fetchBackupStatus(getCurrentUser()?.uid) + commit('loadBackupStatusFromServer', status) + } catch (e) { + // Ignore missing user backup status + } }, async revertBackupFromServer({ commit }, { messageId }) {