Skip to content

Commit

Permalink
fix(chat): Fix manage attachments modal doesn't reflect file deletion…
Browse files Browse the repository at this point in the history
…s without page refresh (Issue #2685)  (#2999)
  • Loading branch information
denys-kolomiitsev authored Jan 23, 2025
1 parent 0f685e7 commit 57551ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/chat/src/components/Files/FileManagerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ export const FileManagerModal = ({

useEffect(() => {
if (isOpen) {
dispatch(FilesActions.resetAllFoldersStatus());

dispatch(FilesActions.getFilesWithFolders({}));
dispatch(FilesActions.resetNewFolderId());
}
Expand Down
12 changes: 11 additions & 1 deletion apps/chat/src/store/files/files.reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ export const filesSlice = createSlice({

state.files = mappedFiles.concat(
state.files.filter(
(file) => !mappedFiles.find((stateFile) => stateFile.id === file.id),
(stateFile) =>
//remove all files from loaded folder to have latest folder update
!mappedFiles.find(
(mappedFile) => mappedFile.folderId === stateFile.folderId,
),
),
);
state.filesStatus = UploadStatus.LOADED;
Expand Down Expand Up @@ -420,6 +424,12 @@ export const filesSlice = createSlice({
contentType: string;
}>,
) => state,
resetAllFoldersStatus: (state) => {
state.folders = state.folders.map((folder) => ({
...folder,
status: UploadStatus.UNINITIALIZED,
}));
},
},
});

Expand Down

0 comments on commit 57551ad

Please sign in to comment.