Skip to content

Commit

Permalink
Indicate results of updatedVersionedMetafile thunk including reasons …
Browse files Browse the repository at this point in the history
…for failure to update
  • Loading branch information
nelsonni committed Jun 3, 2022
1 parent 4538678 commit 56152e7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/store/thunks/metafiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ export const updatedVersionedMetafile = createAsyncThunk<VersionedMetafile | Fil
const status = await getStatus(metafile.path);
const conflicted = await checkFilepath(metafile.path);

if ((isDefined(repo) && isDefined(branch) && isDefined(status)
&& isUpdateable<Metafile>(metafile, { repo: repo.id, branch: branch.id, status, conflicts: conflicted ? conflicted.conflicts : [] }))) {
console.log(`updatedVersionedMetafile`, { metafile }, `updating with => repo: ${repo.id}, branch: ${branch.id}, statu: ${status}`);
} else {
const reasons: string[] = [];
if (!isDefined(repo)) reasons.push('repo undefined');
if (!isDefined(branch)) reasons.push('branch undefined');
if (!isDefined(status)) reasons.push('status undefined');
if ((isDefined(repo) && isDefined(branch) && isDefined(status)
&& !isUpdateable<Metafile>(metafile, { repo: repo.id, branch: branch.id, status, conflicts: conflicted ? conflicted.conflicts : [] }))) reasons.push('not updateable');
console.log(`updatedVersionedMetafile`, { metafile }, `unable to update`, { reasons });
}

return (isDefined(repo) && isDefined(branch) && isDefined(status)
&& isUpdateable<Metafile>(metafile, { repo: repo.id, branch: branch.id, status, conflicts: conflicted ? conflicted.conflicts : [] })) ?
thunkAPI.dispatch(metafileUpdated({
Expand Down

0 comments on commit 56152e7

Please sign in to comment.