Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reloading the loader and other components on sharing #1391

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,7 @@ const CopyToSharedFolderModal = ({ close, file, filePath }: IShareFileProps) =>
const classes = useStyles()
const { isCreatingSharedFolder, handleCreateSharedFolder } = useCreateOrEditSharedFolder()
const [sharedFolderName, setSharedFolderName] = useState("")
const {
sharedFolderReaders,
sharedFolderWriters,
handleLookupUser,
onNewUsers,
usersError
} = useLookupSharedFolderUser()
const { sharedFolderReaders, sharedFolderWriters, handleLookupUser, onNewUsers, usersError } = useLookupSharedFolderUser()
const [isUsingCurrentBucket, setIsUsingCurrentBucket] = useState(true)
const [currentStep, setCurrentStep] = useState<Step>("1_SHARED_FOLDER_SELECTION_CREATION")
const [destinationBucket, setDestinationBucket] = useState<BucketKeyPermission | undefined>()
Expand Down Expand Up @@ -285,7 +279,6 @@ const CopyToSharedFolderModal = ({ close, file, filePath }: IShareFileProps) =>
let fileContent: Blob | undefined

try {
console.log("filePath", filePath)
fileContent = await getFile({ file, filePath })
} catch(e) {
setError(t`Error while downloading ${file.name}`)
Expand Down Expand Up @@ -334,7 +327,7 @@ const CopyToSharedFolderModal = ({ close, file, filePath }: IShareFileProps) =>
}
}, [close, currentStep])

const Loader = () => (
const Loader = useCallback(() => (
<div className={classes.loadingContainer}>
<Loading
size={48}
Expand All @@ -354,9 +347,9 @@ const CopyToSharedFolderModal = ({ close, file, filePath }: IShareFileProps) =>
{isUploading && <Trans>Encrypting and uploading…</Trans>}
</Typography>
</div>
)
), [classes.loadingContainer, isDownloading, isUploading])

const Step1CreateSharedFolder = () => (
const Step1CreateSharedFolder = useCallback(() => (
<>
<div className={classes.modalFlexItem}>
<TextInput
Expand Down Expand Up @@ -401,9 +394,18 @@ const CopyToSharedFolderModal = ({ close, file, filePath }: IShareFileProps) =>
}}/>
</div>
</>
)
), [
classes.inputLabel,
classes.modalFlexItem,
classes.shareFolderNameInput,
handleLookupUser,
onNewUsers,
sharedFolderName,
sharedFolderReaders,
sharedFolderWriters
])

const Step1ExistingSharedFolder = () => (
const Step1ExistingSharedFolder = useCallback(() => (
<div className={clsx(classes.modalFlexItem, classes.inputWrapper)}>
<SelectInput
label={t`Select an existing shared folder`}
Expand All @@ -413,7 +415,7 @@ const CopyToSharedFolderModal = ({ close, file, filePath }: IShareFileProps) =>
onChange={(val: string) => setDestinationBucket(buckets.find((bu) => bu.id === val))}
/>
</div>
)
), [buckets, bucketsOptions, classes.inputLabel, classes.inputWrapper, classes.modalFlexItem, destinationBucket])

return (
<CustomModal
Expand Down