refactor: Handle errors when importing collections (#2455)

This commit is contained in:
Sanjai Kumar 2024-06-17 12:24:25 +05:30 committed by GitHub
parent 693f882f5a
commit 5c04f884e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 8 deletions

View File

@ -31,10 +31,17 @@ const TitleBar = () => {
};
const handleImportCollectionLocation = (collectionLocation) => {
dispatch(importCollection(importedCollection, collectionLocation));
dispatch(importCollection(importedCollection, collectionLocation))
.then(() => {
setImportCollectionLocationModalOpen(false);
setImportedCollection(null);
toast.success('Collection imported successfully');
})
.catch((err) => {
setImportCollectionLocationModalOpen(false);
console.error(err);
toast.error('An error occurred while importing the collection. Check the logs for more information.');
});
};
const menuDropdownTippyRef = useRef();

View File

@ -34,10 +34,17 @@ const Welcome = () => {
};
const handleImportCollectionLocation = (collectionLocation) => {
dispatch(importCollection(importedCollection, collectionLocation));
dispatch(importCollection(importedCollection, collectionLocation))
.then(() => {
setImportCollectionLocationModalOpen(false);
setImportedCollection(null);
toast.success('Collection imported successfully');
})
.catch((err) => {
setImportCollectionLocationModalOpen(false);
console.error(err);
toast.error('An error occurred while importing the collection. Check the logs for more information.');
});
};
return (