feat(#162): [Tilak|Pooja] Update app id when settings context is present in db but not app id

This commit is contained in:
Tilak Puli
2023-07-08 17:06:42 +05:30
parent a124f83469
commit c84632990d

View File

@@ -60,6 +60,11 @@ export const settingsMachine = model.createMachine(
entry: ['requestStoredContext'],
on: {
STORE_RESPONSE: [
{
cond: 'hasPartialData',
target: 'idle',
actions: ['setContext', 'updatePartialDefaults', 'storeContext'],
},
{ cond: 'hasData', target: 'idle', actions: ['setContext'] },
{ target: 'storingDefaults' },
],
@@ -116,6 +121,10 @@ export const settingsMachine = model.createMachine(
appId: generateAppId(),
}),
updatePartialDefaults: model.assign({
appId: (context) => context.appId || generateAppId(),
}),
storeContext: send(
(context) => {
const { serviceRefs, ...data } = context;
@@ -180,6 +189,8 @@ export const settingsMachine = model.createMachine(
guards: {
hasData: (_, event) => event.response != null,
hasPartialData: (_, event) =>
event.response != null && event.response.appId == null,
},
}
);