diff --git a/webapp/src/store/attachments.ts b/webapp/src/store/attachments.ts index 914ce7a94..ee55701cb 100644 --- a/webapp/src/store/attachments.ts +++ b/webapp/src/store/attachments.ts @@ -46,7 +46,11 @@ const attachmentSlice = createSlice({ } }, updateUploadPrecent: (state, action: PayloadAction<{blockId: string, uploadPercent: number}>) => { - state.attachments[action.payload.blockId].uploadingPercent = action.payload.uploadPercent + const attachment = state.attachments[action.payload.blockId] + if (!attachment) { + return + } + attachment.uploadingPercent = action.payload.uploadPercent }, }, extraReducers: (builder) => { @@ -88,6 +92,6 @@ export function getCardAttachments(cardId: string): (state: RootState) => Attach export function getUploadPercent(blockId: string): (state: RootState) => number { return (state: RootState): number => { - return (state.attachments.attachments[blockId].uploadingPercent) + return state.attachments.attachments[blockId]?.uploadingPercent ?? 0 } }