Skip to content

Commit

Permalink
fix: history log for batch revoke
Browse files Browse the repository at this point in the history
  • Loading branch information
pmigueld committed Sep 13, 2022
1 parent 5d894a8 commit 69ba306
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 234 deletions.
6 changes: 4 additions & 2 deletions machines/activityLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const model = createModel(
{
events: {
STORE_RESPONSE: (response: unknown) => ({ response }),
LOG_ACTIVITY: (log: ActivityLog) => ({ log }),
LOG_ACTIVITY: (log: ActivityLog | ActivityLog[]) => ({ log }),
REFRESH: () => ({}),
},
}
Expand Down Expand Up @@ -93,7 +93,9 @@ export const activityLogMachine =

prependActivity: model.assign({
activities: (context, event) =>
[event.response, ...context.activities] as ActivityLog[],
(Array.isArray(event.response)
? [...event.response, ...context.activities]
: [event.response, ...context.activities]) as ActivityLog[],
}),
},
}
Expand Down
9 changes: 7 additions & 2 deletions machines/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { createVcMachine, vcMachine } from './vc';
import { createActivityLogMachine, activityLogMachine } from './activityLog';
import { createRequestMachine, requestMachine } from './request';
import { createScanMachine, scanMachine } from './scan';
import { createRevoke, revokeVidsMachine } from './revoke';
import { createRevokeMachine, revokeVidsMachine } from './revoke';

import { pure, respond } from 'xstate/lib/actions';
import { AppServices } from '../shared/GlobalContext';
Expand Down Expand Up @@ -174,15 +174,19 @@ export const appMachine = model.createMachine(
const serviceRefs = {
...context.serviceRefs,
};

serviceRefs.auth = spawn(
createAuthMachine(serviceRefs),
authMachine.id
);

serviceRefs.vc = spawn(createVcMachine(serviceRefs), vcMachine.id);

serviceRefs.settings = spawn(
createSettingsMachine(serviceRefs),
settingsMachine.id
);

serviceRefs.activityLog = spawn(
createActivityLogMachine(serviceRefs),
activityLogMachine.id
Expand All @@ -192,13 +196,14 @@ export const appMachine = model.createMachine(
createScanMachine(serviceRefs),
scanMachine.id
);

serviceRefs.request = spawn(
createRequestMachine(serviceRefs),
requestMachine.id
);

serviceRefs.revoke = spawn(
createRevoke(serviceRefs),
createRevokeMachine(serviceRefs),
revokeVidsMachine.id
);

Expand Down
Loading

0 comments on commit 69ba306

Please sign in to comment.