Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added backward compatility to old action types #3776

Merged
merged 7 commits into from
Aug 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -136,36 +136,33 @@ export class StratosBaseCatalogueEntity<
subType
};
}

public getRequestAction(
actionString: 'start' | 'success' | 'failure' | 'complete',
requestType: ApiRequestTypes,
action?: EntityRequestAction,
response?: any): APISuccessOrFailedAction {
// backward compatibility with the old actions.
// it should be removed after everything is based on the new flow
// Backward compatibility with the old actions.
// This should be removed after everything is based on the new flow
private getLegacyTypeFromAction(
action: EntityRequestAction,
actionString: 'start' | 'success' | 'failure' | 'complete'
) {
if (action && action.actions) {
let type;

switch (actionString) {
case 'success':
type = action.actions[1];
break;
return action.actions[1];
case 'failure':
type = action.actions[2];
break;
return action.actions[2];
case 'start':
type = action.actions[0];
break;
}

if (type) {
return new APISuccessOrFailedAction(type, action, response);
return action.actions[0];
}
}
return null;
}

return new APISuccessOrFailedAction(`@stratos/${this.entityKey}/${requestType}/${actionString}`,
action, response);
public getRequestAction(
actionString: 'start' | 'success' | 'failure' | 'complete',
requestType: ApiRequestTypes,
action?: EntityRequestAction,
response?: any
): APISuccessOrFailedAction {
const type = this.getLegacyTypeFromAction(action, actionString) || `@stratos/${this.entityKey}/${requestType}/${actionString}`;
return new APISuccessOrFailedAction(type, action, response);
}

public getNormalizedEntityData(entities: Y | Y[], schemaKey?: string): NormalizedResponse<Y> {