Skip to content

Commit

Permalink
fix(discoverability): simplify getStatus logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenCodes committed Sep 28, 2020
1 parent f23da62 commit bbb67e5
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/store/eventing/staged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,11 @@ type Status = 'create' | 'update' | 'cancel';
type Type = 'highlight' | 'region';

export const getStatus = (prevStaged: CreatorItem, nextStaged: CreatorItem): Status | null => {
let status: Status | null = null;

if (prevStaged === null && nextStaged === null) {
status = 'cancel';
}

if (prevStaged === null && nextStaged !== null) {
status = 'create';
}

if (prevStaged !== null) {
status = nextStaged === null ? 'cancel' : 'update';
if (nextStaged === null) {
return 'cancel';
}

return status;
return prevStaged ? 'update' : 'create';
};

export const getType = (staged: CreatorItem): Type | null => {
Expand Down

0 comments on commit bbb67e5

Please sign in to comment.