ui(server): fix file uploads being canceled instead of completed

This commit is contained in:
Matthew Penner 2022-12-04 16:36:53 -07:00
parent 158facd534
commit 598c956e4e
No known key found for this signature in database
3 changed files with 25 additions and 16 deletions

View file

@ -21,6 +21,7 @@ export interface ServerFileStore {
setUploadProgress: Action<ServerFileStore, { name: string; loaded: number }>;
clearFileUploads: Action<ServerFileStore>;
removeFileUpload: Action<ServerFileStore, string>;
cancelFileUpload: Action<ServerFileStore, string>;
}
const files: ServerFileStore = {
@ -61,6 +62,12 @@ const files: ServerFileStore = {
}),
removeFileUpload: action((state, payload) => {
if (state.uploads[payload]) {
delete state.uploads[payload];
}
}),
cancelFileUpload: action((state, payload) => {
if (state.uploads[payload]) {
// Abort the request if it is still in flight. If it already completed this is
// a no-op.