Skip to content

Commit

Permalink
fix: selected items when stop sharing item for shared view
Browse files Browse the repository at this point in the history
  • Loading branch information
masterprog-cmd committed Sep 25, 2024
1 parent d6d18d7 commit 73bc121
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/app/drive/components/DriveExplorer/DriveExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,10 @@ const DriveExplorer = (props: DriveExplorerProps): JSX.Element => {
);

const handleOnShareItem = useCallback(() => {
resetPaginationState();
dispatch(fetchSortedFolderContentThunk(currentFolderId));
setTimeout(() => {
resetPaginationState();
dispatch(fetchSortedFolderContentThunk(currentFolderId));
}, 500);
}, [currentFolderId]);

const onSuccessEditingName = useCallback(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/app/drive/components/ShareDialog/ShareDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type ShareDialogProps = {
user: UserSettings;
isDriveItem?: boolean;
onShareItem?: () => void;
onStopSharingItem?: () => void;
onCloseDialog?: () => void;
};

Expand Down Expand Up @@ -463,6 +464,7 @@ const ShareDialog = (props: ShareDialogProps): JSX.Element => {
}),
);
props.onShareItem?.();
props.onStopSharingItem?.();
setShowStopSharingConfirmation(false);
onClose();
setIsLoading(false);
Expand Down
18 changes: 12 additions & 6 deletions src/app/share/views/SharedLinksView/SharedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ function SharedView({
: translate('shared-links.toast.link-deleted');
notificationsService.show({ text: stringLinksDeleted, type: ToastType.Success });
closeConfirmDelete();
actionDispatch(setSelectedItems([]));
actionDispatch(setIsLoading(false));
}
};
Expand All @@ -313,6 +314,8 @@ function SharedView({
}));

await moveItemsToTrash(itemsToTrash, () => removeItemsFromList(itemsToTrash));

actionDispatch(setSelectedItems([]));
};

const renameItem = (shareItem: AdvancedSharedItem | DriveItemData) => {
Expand All @@ -330,14 +333,14 @@ function SharedView({
const mnemonic =
selectedWorkspace?.workspaceUser.key ??
(await decryptMnemonic(shareItem.encryptionKey ? shareItem.encryptionKey : clickedShareItemEncryptionKey));
handleOpemItemPreview(true, { ...previewItem, mnemonic });
handleOpenItemPreview(true, { ...previewItem, mnemonic });
} catch (err) {
const error = errorService.castError(err);
errorService.reportError(error);
}
};

const handleOpemItemPreview = (openItemPreview: boolean, item?: PreviewFileItem) => {
const handleOpenItemPreview = (openItemPreview: boolean, item?: PreviewFileItem) => {
actionDispatch(setItemToView(item));
actionDispatch(setIsFileViewerOpen(openItemPreview));
};
Expand Down Expand Up @@ -465,7 +468,7 @@ function SharedView({
await moveSelectedItemsToTrash(items);

if (isFileViewerOpen) {
handleOpemItemPreview(false);
handleOpenItemPreview(false);
}
};

Expand Down Expand Up @@ -536,7 +539,7 @@ function SharedView({
onOpenStopSharingDialog={onOpenStopSharingDialog}
onRenameSelectedItem={renameItem}
onOpenItemPreview={(item: PreviewFileItem) => {
handleOpemItemPreview(true, item);
handleOpenItemPreview(true, item);
}}
/>
</div>
Expand All @@ -558,7 +561,7 @@ function SharedView({
<FileViewerWrapper
file={itemToView}
showPreview={isFileViewerOpen}
onClose={() => handleOpemItemPreview(false)}
onClose={() => handleOpenItemPreview(false)}
onShowStopSharingDialog={onOpenStopSharingDialog}
sharedKeyboardShortcuts={{
renameItemFromKeyboard: !isCurrentUserViewer(currentUserRole) ? renameItem : undefined,
Expand All @@ -574,7 +577,10 @@ function SharedView({
moveItemsToTrash={moveItemsToTrashOnStopSharing}
/>
<ItemDetailsDialog onDetailsButtonClicked={handleDetailsButtonClicked} />
<ShareDialog onCloseDialog={handleOnCloseShareDialog} />
<ShareDialog
onCloseDialog={handleOnCloseShareDialog}
onStopSharingItem={() => actionDispatch(setSelectedItems([]))}
/>
{isShowInvitationsOpen && <ShowInvitationsDialog onClose={onShowInvitationsModalClose} />}
<DeleteDialog
isOpen={isDeleteDialogModalOpen && selectedItems.length > 0}
Expand Down

0 comments on commit 73bc121

Please sign in to comment.