fix(ui): fix deleting image does not refresh board

I had some some wonkiness in the thunks
This commit is contained in:
psychedelicious 2023-06-23 22:20:08 +10:00
parent 8e724b5abe
commit 3619c86f07
2 changed files with 11 additions and 14 deletions

View File

@ -38,7 +38,7 @@ export const imageUrlsReceived = createAppAsyncThunk<
} }
); );
if (error || !data) { if (error) {
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }
@ -73,7 +73,7 @@ export const imageMetadataReceived = createAppAsyncThunk<
} }
); );
if (error || !data) { if (error) {
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }
@ -163,10 +163,11 @@ export const imageUploaded = createAppAsyncThunk<
}, },
// TODO: Proper handling of `multipart/form-data` is coming soon, will fix type issues // TODO: Proper handling of `multipart/form-data` is coming soon, will fix type issues
// https://github.com/drwpow/openapi-typescript/issues/1123 // https://github.com/drwpow/openapi-typescript/issues/1123
// @ts-ignore
body: formData, body: formData,
}); });
if (error || !data) { if (error) {
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }
@ -202,11 +203,9 @@ export const imageDeleted = createAppAsyncThunk<
}, },
}); });
if (error || !data) { if (error) {
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }
return data;
}); });
type UpdateImageArg = type UpdateImageArg =
@ -244,7 +243,7 @@ export const imageUpdated = createAppAsyncThunk<
}, },
}); });
if (error || !data) { if (error) {
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }
@ -313,7 +312,7 @@ export const receivedPageOfImages = createAppAsyncThunk<
}, },
}); });
if (error || !data) { if (error) {
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }

View File

@ -41,7 +41,7 @@ export const sessionCreated = createAppAsyncThunk<
body: graph, body: graph,
}); });
if (error || !data) { if (error) {
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }
@ -81,14 +81,12 @@ export const sessionInvoked = createAppAsyncThunk<
} }
); );
if (error || !data) { if (error) {
if (isErrorWithStatus(error) && error.status === 403) { if (isErrorWithStatus(error) && error.status === 403) {
return rejectWithValue({ arg, error: (error as any).body.detail }); return rejectWithValue({ arg, error: (error as any).body.detail });
} }
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }
return data;
}); });
type CancelSessionArg = type CancelSessionArg =
@ -123,7 +121,7 @@ export const sessionCanceled = createAppAsyncThunk<
} }
); );
if (error || !data) { if (error) {
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }
@ -157,7 +155,7 @@ export const listedSessions = createAppAsyncThunk<
params, params,
}); });
if (error || !data) { if (error) {
return rejectWithValue({ arg, error }); return rejectWithValue({ arg, error });
} }