feat: reopen library menu on import from file (#3383)

Co-authored-by: Thang Vu <thang.huu.vu@mgm-tp.com>
This commit is contained in:
Thang Vu 2021-04-04 19:06:10 +07:00 committed by GitHub
parent 233576628c
commit 67289ef4ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -3624,7 +3624,9 @@ class App extends React.Component<AppProps, AppState> {
) {
Library.importLibrary(file)
.then(() => {
// Close and then open to get the libraries updated
this.setState({ isLibraryOpen: false });
this.setState({ isLibraryOpen: true });
})
.catch((error) =>
this.setState({ isLoading: false, errorMessage: error.message }),

View File

@ -142,9 +142,9 @@ const LibraryMenuItems = ({
onClick={() => {
importLibraryFromJSON()
.then(() => {
// Maybe we should close and open the menu so that the items get updated.
// But for now we just close the menu.
// Close and then open to get the libraries updated
setAppState({ isLibraryOpen: false });
setAppState({ isLibraryOpen: true });
})
.catch(muteFSAbortError)
.catch((error) => {

View File

@ -116,5 +116,5 @@ export const importLibraryFromJSON = async () => {
extensions: [".json", ".excalidrawlib"],
*/
});
Library.importLibrary(blob);
await Library.importLibrary(blob);
};