Client: update Share tab if share by quick button
This commit is contained in:
parent
d17a7d7abb
commit
1edade0747
@ -54,11 +54,12 @@ export default function withQuickButtons(WrappedComponent) {
|
||||
};
|
||||
|
||||
onClickShare = async () => {
|
||||
const { t, item, getPrimaryFileLink } = this.props;
|
||||
const { t, item, getPrimaryFileLink, setShareChanged } = this.props;
|
||||
const primaryLink = await getPrimaryFileLink(item.id);
|
||||
if (primaryLink) {
|
||||
copy(primaryLink.sharedTo.shareLink);
|
||||
toastr.success(t("Files:LinkSuccessfullyCopied"));
|
||||
setShareChanged(true);
|
||||
}
|
||||
};
|
||||
|
||||
@ -142,7 +143,7 @@ export default function withQuickButtons(WrappedComponent) {
|
||||
isTrashFolder || isArchiveFolderRoot || isPersonalFolderRoot;
|
||||
|
||||
const { isPublicRoom } = publicRoomStore;
|
||||
const { getPrimaryFileLink } = auth.infoPanelStore;
|
||||
const { getPrimaryFileLink, setShareChanged } = auth.infoPanelStore;
|
||||
|
||||
return {
|
||||
theme: auth.settingsStore.theme,
|
||||
@ -157,6 +158,7 @@ export default function withQuickButtons(WrappedComponent) {
|
||||
getPrimaryLink: filesStore.getPrimaryLink,
|
||||
isArchiveFolder,
|
||||
getPrimaryFileLink,
|
||||
setShareChanged,
|
||||
};
|
||||
}
|
||||
)(observer(WithQuickButtons));
|
||||
|
@ -25,12 +25,15 @@ const Share = (props) => {
|
||||
getFileLinks,
|
||||
editFileLink,
|
||||
addFileLink,
|
||||
shareChanged,
|
||||
setShareChanged,
|
||||
} = props;
|
||||
const { t } = useTranslation(["SharingPanel", "Files"]);
|
||||
const [primaryFileLink, setPrimaryFileLink] = useState([]);
|
||||
const [additionalFileLinks, setAdditionalFileLinks] = useState([]);
|
||||
|
||||
const hideSharePanel = isRooms || !selection?.canShare;
|
||||
console.log("shareChanged", shareChanged);
|
||||
|
||||
useEffect(() => {
|
||||
if (hideSharePanel) {
|
||||
@ -39,6 +42,11 @@ const Share = (props) => {
|
||||
fetchLinks();
|
||||
}, [selection]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchLinks();
|
||||
setShareChanged(false);
|
||||
}, [shareChanged]);
|
||||
|
||||
const fetchLinks = async () => {
|
||||
const res = await getFileLinks(selection.id);
|
||||
const primaryLink = res.items.filter(
|
||||
@ -107,8 +115,12 @@ const Share = (props) => {
|
||||
}
|
||||
} else {
|
||||
updateLink(link, res);
|
||||
copy(link.sharedTo.shareLink);
|
||||
toastr.success(t("Files:LinkSuccessfullyCopied"));
|
||||
if (item.access === ShareAccessRights.DenyAccess) {
|
||||
toastr.success(t("Files:AccessDenied"));
|
||||
} else {
|
||||
copy(link.sharedTo.shareLink);
|
||||
toastr.success(t("Files:LinkSuccessfullyCopied"));
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
toastr.error(e);
|
||||
@ -216,6 +228,8 @@ export default inject(({ auth }) => {
|
||||
getFileLinks,
|
||||
editFileLink,
|
||||
addFileLink,
|
||||
shareChanged,
|
||||
setShareChanged,
|
||||
} = auth.infoPanelStore;
|
||||
|
||||
return {
|
||||
@ -224,5 +238,7 @@ export default inject(({ auth }) => {
|
||||
getFileLinks,
|
||||
editFileLink,
|
||||
addFileLink,
|
||||
shareChanged,
|
||||
setShareChanged,
|
||||
};
|
||||
})(observer(Share));
|
||||
|
@ -53,6 +53,8 @@ class InfoPanelStore {
|
||||
treeFoldersStore = null;
|
||||
membersList = null;
|
||||
|
||||
shareChanged = false;
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
@ -229,14 +231,14 @@ class InfoPanelStore {
|
||||
return item.isRoom || !!item.roomType
|
||||
? item.rootFolderType === FolderType.Archive
|
||||
? item.logo && item.logo.medium
|
||||
: this.settingsStore.getIcon(
|
||||
size,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
item.roomType,
|
||||
true
|
||||
)
|
||||
: this.settingsStore.getIcon(
|
||||
size,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
item.roomType,
|
||||
true
|
||||
)
|
||||
? item.logo.medium
|
||||
: item.icon
|
||||
? item.icon
|
||||
@ -402,6 +404,10 @@ class InfoPanelStore {
|
||||
await getFileInfo(fileId);
|
||||
return res;
|
||||
};
|
||||
|
||||
setShareChanged = (shareChanged) => {
|
||||
this.shareChanged = shareChanged;
|
||||
};
|
||||
}
|
||||
|
||||
export default InfoPanelStore;
|
||||
|
Loading…
Reference in New Issue
Block a user