From 8f053793f0663e98c3b0317d0ec29780c0b19ae9 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Tue, 13 Aug 2024 22:09:22 +0300 Subject: [PATCH] spinner when creating document --- ng-app/src/lib/FullLayout.svelte | 25 +++++++++++++++++++++++-- ng-app/src/locales/en.json | 1 + ng-app/src/styles.css | 4 ++++ ng-app/src/tab.ts | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ng-app/src/lib/FullLayout.svelte b/ng-app/src/lib/FullLayout.svelte index b649f99..2affb04 100644 --- a/ng-app/src/lib/FullLayout.svelte +++ b/ng-app/src/lib/FullLayout.svelte @@ -28,6 +28,7 @@ import TxtIcon from "./icons/TxtIcon.svelte"; // @ts-ignore import Logo from "./components/Logo.svelte"; + import Spinner from "./components/Spinner.svelte"; import MenuItem from "./components/MenuItem.svelte"; import PaneHeader from "./components/PaneHeader.svelte"; import BranchIcon from "./icons/BranchIcon.svelte"; @@ -39,7 +40,7 @@ available_editors, available_viewers, set_editor, set_viewer, set_view_or_edit, toggle_live_edit, has_editor_chat, all_files_count, all_comments_count, hideMenu, show_modal_menu, show_modal_create, cur_tab_branch_nuri, cur_tab_doc_can_edit, cur_tab_doc_is_member, cur_tab_right_pane, cur_tab_folders_pane, - cur_tab_toc_pane, cur_tab_show_menu, cur_tab_branch_has_discrete, cur_tab_graph_or_discrete, cur_tab_view_or_edit } from "../tab"; + cur_tab_toc_pane, cur_tab_show_menu, cur_tab_branch_has_discrete, cur_tab_graph_or_discrete, cur_tab_view_or_edit, show_spinner } from "../tab"; import { active_session, redirect_after_login, toasts, check_has_camera, toast_error, reset_toasts, @@ -506,6 +507,12 @@ return ct; }); } + const openSpinner = () => { + $show_spinner = true; + } + const closeSpinner = () => { + $show_spinner = false; + } const share_items = [ {n:"repost",i:Bolt}, @@ -554,6 +561,7 @@ const new_document = async (class_name) => { closeModalCreate(); + openSpinner(); try { await reset_toasts(); let store_repo = $cur_tab.store.repo; @@ -561,9 +569,11 @@ store_repo = $all_tabs[$active_session.private_store_id].store.repo } let nuri = await ng.doc_create($active_session.session_id, get_class(class_name)["ng:crdt"], class_name, store_repo, destination); + closeSpinner(); push("#/"+nuri); } catch (e) { + closeSpinner(); toast_error(display_error(e)); } } @@ -894,7 +904,18 @@ {/if} - + +

{$t("doc.creating")}...

+
+ +
+
{ } export const show_modal_menu = writable(false); - +export const show_spinner = writable(false); export const show_modal_create = writable(false); export const in_memory_graph = writable("");