mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-03 08:21:07 +00:00
fix(errors): snackbars for 502 and notification not found errors should have timeout (#10394)
This commit is contained in:
parent
fc62db147f
commit
eaf0c62e16
1 changed files with 17 additions and 7 deletions
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue