1
Fork 0
mirror of https://github.com/diced/zipline.git synced 2025-04-11 23:31:17 -05:00

fix: apply loading and disabled to text upload button

This commit is contained in:
diced 2024-07-07 12:31:23 -07:00
parent 70050afb5f
commit 7f9de82804
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1

View file

@ -22,6 +22,7 @@ export default function Text() {
const [value, setValue] = useState('');
const [lang, setLang] = useState('txt');
const [loading, setLoading] = useState(false);
const [options, setOpened, OptionsModal] = useUploadOptions();
@ -29,6 +30,9 @@ export default function Text() {
const shouldRenderTex = lang === 'tex';
const handleUpload = async () => {
if (value.trim().length === 0) return;
setLoading(true);
const file = new File([value], 'text.' + lang);
const expiresAt = options.expires === 'never' ? null : expireReadToDate(options.expires);
@ -53,6 +57,16 @@ export default function Text() {
message: '',
});
showFilesModal(clipboard, modals, json.files);
setLoading(false);
setValue('');
} else {
updateNotification({
id: 'upload-text',
title: 'Upload Failed',
message: json.error,
color: 'red',
});
setLoading(false);
}
});
@ -136,7 +150,8 @@ export default function Text() {
<Button
leftIcon={<IconFileUpload size='1rem' />}
onClick={handleUpload}
disabled={value.trim().length === 0 ? true : false}
disabled={value.trim().length === 0 || loading}
loading={loading}
>
Upload
</Button>