fix: Improvements in share feat (#2502)
* Make request only when popover is visible * Update policies required for shares.create shares.update * Create withCollection scope * Remove team share check from shares.create * Update tests
This commit is contained in:
@@ -61,6 +61,7 @@ function ShareButton({ document }: Props) {
|
||||
share={share}
|
||||
sharedParent={sharedParent}
|
||||
onSubmit={popover.hide}
|
||||
visible={popover.visible}
|
||||
/>
|
||||
</Popover>
|
||||
</>
|
||||
|
||||
@@ -23,9 +23,16 @@ type Props = {|
|
||||
share: Share,
|
||||
sharedParent: ?Share,
|
||||
onSubmit: () => void,
|
||||
visible: boolean,
|
||||
|};
|
||||
|
||||
function SharePopover({ document, share, sharedParent, onSubmit }: Props) {
|
||||
function SharePopover({
|
||||
document,
|
||||
share,
|
||||
sharedParent,
|
||||
onSubmit,
|
||||
visible,
|
||||
}: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { policies, shares, auth } = useStores();
|
||||
const { showToast } = useToasts();
|
||||
@@ -41,9 +48,9 @@ function SharePopover({ document, share, sharedParent, onSubmit }: Props) {
|
||||
const isPubliclyShared = (share && share.published) || sharedParent;
|
||||
|
||||
React.useEffect(() => {
|
||||
document.share();
|
||||
if (visible) document.share();
|
||||
return () => clearTimeout(timeout.current);
|
||||
}, [document]);
|
||||
}, [document, visible]);
|
||||
|
||||
const handlePublishedChange = React.useCallback(
|
||||
async (event) => {
|
||||
|
||||
Reference in New Issue
Block a user