Skip to content

Commit ba10433

Browse files
show loading when user select's an icon to download
1 parent e955af0 commit ba10433

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

client/packages/lowcoder/src/comps/controls/iconscoutControl.tsx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ export const IconPicker = (props: {
223223
}) => {
224224
const [ visible, setVisible ] = useState(false)
225225
const [ loading, setLoading ] = useState(false)
226+
const [ downloading, setDownloading ] = useState(false)
226227
const [ searchText, setSearchText ] = useState<string>('')
227228
const [ searchResults, setSearchResults ] = useState<Array<any>>([]);
228229

@@ -268,20 +269,24 @@ export const IconPicker = (props: {
268269
}
269270
} catch(error) {
270271
console.error(error);
272+
setDownloading(false);
271273
}
272274
}
273275

274276
const fetchDownloadUrl = async (uuid: string, preview: string) => {
275277
try {
278+
setDownloading(true);
276279
const result = await IconscoutApi.download(uuid, {
277280
format: props.assetType === AssetType.LOTTIE ? 'lottie' : 'svg',
278281
});
279282

280283
downloadAsset(uuid, result.download_url, (assetUrl: string) => {
284+
setDownloading(false);
281285
onChangeIcon(uuid, assetUrl, preview);
282286
});
283287
} catch (error) {
284288
console.error(error);
289+
setDownloading(false);
285290
}
286291
}
287292

@@ -383,24 +388,26 @@ export const IconPicker = (props: {
383388
<Spin indicator={<LoadingOutlined style={{ fontSize: 25 }} spin />} />
384389
</Flex>
385390
)}
386-
{!loading && Boolean(searchText) && !searchResults?.length && (
387-
<Flex align="center" justify="center" style={{flex: 1}}>
388-
<Typography.Text type="secondary">
389-
{trans("iconScout.noResults")}
390-
</Typography.Text>
391-
</Flex>
392-
)}
393-
{!loading && Boolean(searchText) && searchResults?.length && (
394-
<IconListWrapper>
395-
<IconList
396-
width={550}
397-
height={400}
398-
rowHeight={80}
399-
rowCount={Math.ceil(searchResults.length / columnNum)}
400-
rowRenderer={rowRenderer}
401-
/>
402-
</IconListWrapper>
403-
)}
391+
<Spin spinning={downloading} indicator={<LoadingOutlined style={{ fontSize: 25 }} />} >
392+
{!loading && Boolean(searchText) && !searchResults?.length && (
393+
<Flex align="center" justify="center" style={{flex: 1}}>
394+
<Typography.Text type="secondary">
395+
{trans("iconScout.noResults")}
396+
</Typography.Text>
397+
</Flex>
398+
)}
399+
{!loading && Boolean(searchText) && searchResults?.length && (
400+
<IconListWrapper>
401+
<IconList
402+
width={550}
403+
height={400}
404+
rowHeight={80}
405+
rowCount={Math.ceil(searchResults.length / columnNum)}
406+
rowRenderer={rowRenderer}
407+
/>
408+
</IconListWrapper>
409+
)}
410+
</Spin>
404411
</PopupContainer>
405412
</Draggable>
406413
}

0 commit comments

Comments
 (0)