diff --git a/website/client/app.vue b/website/client/app.vue index 8471bb1adb..1cc5d88f34 100644 --- a/website/client/app.vue +++ b/website/client/app.vue @@ -303,12 +303,6 @@ export default { if (error.response.status >= 400) { this.checkForBannedUser(error); - // Check for conditions to reset the user auth - const invalidUserMessage = [this.$t('invalidCredentials'), 'Missing authentication headers.']; - if (invalidUserMessage.indexOf(error.response.data) !== -1) { - this.$store.dispatch('auth:logout'); - } - // Don't show errors from getting user details. These users have delete their account, // but their chat message still exists. let configExists = Boolean(error.response) && Boolean(error.response.config); @@ -321,11 +315,27 @@ export default { const errorData = error.response.data; const errorMessage = errorData.message || errorData; + // Check for conditions to reset the user auth + const invalidUserMessage = [this.$t('invalidCredentials'), 'Missing authentication headers.']; + if (invalidUserMessage.indexOf(errorMessage) !== -1) { + this.$store.dispatch('auth:logout'); + } + + // Most server errors should return is click to dismiss errors, with some exceptions + let snackbarTimeout = false; + if (error.response.status === 502) snackbarTimeout = true; + + const notificationNotFoundMessage = [ + this.$t('messageNotificationNotFound'), + this.$t('messageNotificationNotFound', 'en'), + ]; + if (notificationNotFoundMessage.indexOf(errorMessage) !== -1) snackbarTimeout = true; + this.$store.dispatch('snackbars:add', { title: 'Habitica', text: errorMessage, type: 'error', - timeout: false, + timeout: snackbarTimeout, }); }