From dfdf74a9b4e229ace687d56ea3fb3dc156e35d62 Mon Sep 17 00:00:00 2001 From: thecodrr Date: Tue, 29 Dec 2020 15:16:04 +0500 Subject: [PATCH] fix: crashes in various places --- .../src/components/spliteditor/simpleeditor.js | 2 +- apps/web/src/stores/editor-store.js | 2 +- apps/web/src/views/settings.js | 10 +++++++--- apps/web/yarn.lock | 16 ++++++++++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/apps/web/src/components/spliteditor/simpleeditor.js b/apps/web/src/components/spliteditor/simpleeditor.js index 61ef64149..b7c3b01d1 100644 --- a/apps/web/src/components/spliteditor/simpleeditor.js +++ b/apps/web/src/components/spliteditor/simpleeditor.js @@ -6,7 +6,7 @@ function SimpleEditor(props) { const { delta, container, id, pref } = props; useEffect(() => { const toolbar = document.querySelector(`${container} .ql-toolbar.ql-snow`); - toolbar.remove(); + if (toolbar) toolbar.remove(); }, [container]); return ( }> diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js index 1d0891015..d5954eef5 100644 --- a/apps/web/src/stores/editor-store.js +++ b/apps/web/src/stores/editor-store.js @@ -136,7 +136,7 @@ class EditorStore extends BaseStore { saveLastOpenedNote(!this.get().session.locked && id); - if (!oldSession.index) { + if (!oldSession?.index) { setHashParam({ note: id }, false); } }); diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js index cf82663bb..8f4e860e9 100644 --- a/apps/web/src/views/settings.js +++ b/apps/web/src/views/settings.js @@ -223,9 +223,13 @@ function Settings(props) { sx={{ borderColor: "error" }} variant="list" onClick={async () => { - // if (await showAccountDeleteConfirmation(user.username)) { - // await db.user.deleteUser(); - // } + return showPasswordDialog( + "delete_account", + async ({ password }) => { + await db.user.deleteUser(password); + return true; + } + ); }} >