Skip to content

Commit

Permalink
Merge pull request #168 from hotwax/fix-missing-facilities
Browse files Browse the repository at this point in the history
Fixed: missing facilities causing sideeffects when userprofile response is delayed
  • Loading branch information
adityasharma7 authored Apr 10, 2023
2 parents 219554d + 6d1c0bb commit 6c96688
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import UserState from './UserState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@/i18n'
import emitter from '@/event-bus'
import { DateTime, Settings } from 'luxon';
import { Settings } from 'luxon';
import { updateInstanceUrl, updateToken, resetConfig } from '@/adapter'

const actions: ActionTree<UserState, RootState> = {
Expand Down Expand Up @@ -34,7 +33,7 @@ const actions: ActionTree<UserState, RootState> = {
if (checkPermissionResponse.status === 200 && !hasError(checkPermissionResponse) && checkPermissionResponse.data && checkPermissionResponse.data.hasPermission) {
commit(types.USER_TOKEN_CHANGED, { newToken: resp.data.token })
updateToken(resp.data.token)
dispatch('getProfile')
await dispatch('getProfile')
if (resp.data._EVENT_MESSAGE_ && resp.data._EVENT_MESSAGE_.startsWith("Alert:")) {
// TODO Internationalise text
showToast(translate(resp.data._EVENT_MESSAGE_));
Expand All @@ -49,7 +48,7 @@ const actions: ActionTree<UserState, RootState> = {
} else {
commit(types.USER_TOKEN_CHANGED, { newToken: resp.data.token })
updateToken(resp.data.token)
dispatch('getProfile')
await dispatch('getProfile')
return resp.data;
}
} else if (hasError(resp)) {
Expand Down Expand Up @@ -90,10 +89,6 @@ const actions: ActionTree<UserState, RootState> = {
if (resp.data.userTimeZone) {
Settings.defaultZone = resp.data.userTimeZone;
}
const localTimeZone = DateTime.local().zoneName;
if (resp.data.userTimeZone !== localTimeZone) {
emitter.emit('timeZoneDifferent', { profileTimeZone: resp.data.userTimeZone, localTimeZone});
}
commit(types.USER_INFO_UPDATED, resp.data);
commit(types.USER_CURRENT_FACILITY_UPDATED, resp.data.facilities.length > 0 ? resp.data.facilities[0] : {});
}
Expand Down

0 comments on commit 6c96688

Please sign in to comment.