Skip to content

Commit

Permalink
fix(context): compatible with new storage api
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD authored and njfamirm committed May 18, 2023
1 parent 7e7498a commit 5251ff0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion core/context/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const serverContextFsmConstructor = finiteStateMachineProvider.defineCons
request_failed: {
target: 'loadingFailed',
},
request_failed_404: {
target: 'loadingFailed',
},
request_success: {
target: 'reloading',
},
Expand All @@ -55,6 +58,9 @@ export const serverContextFsmConstructor = finiteStateMachineProvider.defineCons
request_failed: {
target: 'loadingFailed',
},
request_failed_404: {
target: 'loadingFailed',
},
request_success: {
target: 'complete',
},
Expand All @@ -76,6 +82,9 @@ export const serverContextFsmConstructor = finiteStateMachineProvider.defineCons
request_failed: {
target: 'reloadingFailed',
},
request_failed_404: {
target: 'reloadingFailed',
},
request_success: {
target: 'complete',
},
Expand Down Expand Up @@ -122,12 +131,19 @@ finiteStateMachineProvider.defineActions<ServerContextFsm>(serverContextFsmConst
try {
const {response, options} = fsm.getContext();
if (options == null || options.url == null) {
return logger.error('action_request', 'invalid_fetch_options', {id: fsm.id, options});
logger.error('action_request', 'invalid_fetch_options', {id: fsm.id, options});
return;
}
const newResponse = await serviceRequest<NonNullable<ServerContextFsmContext['response']>>(
options as StringifyableFetchOptions,
);

if (newResponse.data == null) {
logger.accident('requestOrderStorageContext', 'context_not_found', 'Server request 404 not found');
fsm.transition('request_failed_404');
return;
}

if (
response != null &&
newResponse.meta?.lastUpdated != null &&
Expand Down

0 comments on commit 5251ff0

Please sign in to comment.