From 6f3e7b16eb8a89bdfd466ef67bcb081359985554 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Sun, 11 Aug 2024 12:53:22 +0300 Subject: [PATCH] spinners for data loading --- ng-app/src/apps/AutomergeEditor.svelte | 47 ++++++++++--- ng-app/src/apps/ContainerView.svelte | 18 ++--- ng-app/src/apps/PostMdViewer.svelte | 32 ++++++++- ng-app/src/apps/ProseMirrorViewer.svelte | 32 ++++++++- ng-app/src/apps/TextViewer.svelte | 30 ++++++++- ng-app/src/apps/YMapViewer.svelte | 31 ++++++++- ng-app/src/lib/Document.svelte | 84 ++++++++++++++++++++++-- ng-app/src/routes/WalletCreate.svelte | 4 +- ngaccount/web/src/routes/Create.svelte | 2 +- 9 files changed, 252 insertions(+), 28 deletions(-) diff --git a/ng-app/src/apps/AutomergeEditor.svelte b/ng-app/src/apps/AutomergeEditor.svelte index b3a3790..4f4653a 100644 --- a/ng-app/src/apps/AutomergeEditor.svelte +++ b/ng-app/src/apps/AutomergeEditor.svelte @@ -38,6 +38,7 @@ export let readonly = false; let doc = {}; + let loading = true; let safari_error = false; @@ -87,6 +88,8 @@ root_proxy = d; }); + loading = false; + }); async function update(event) { @@ -126,19 +129,47 @@ {#if safari_error} {$t("errors.no_wasm_on_old_safari")} {:else} + {#if loading} +
+ + + + +

{$t("connectivity.loading")}...

+
+ {/if} {#if Object.keys(doc).length !== 0 || !readonly}
{:else if $cur_tab_doc_can_edit} - +
+ +
{:else}

{$t("doc.empty")}

{/if} diff --git a/ng-app/src/apps/ContainerView.svelte b/ng-app/src/apps/ContainerView.svelte index eea99d8..ba0ca0e 100644 --- a/ng-app/src/apps/ContainerView.svelte +++ b/ng-app/src/apps/ContainerView.svelte @@ -50,14 +50,14 @@ {#if commits.graph.length == 0 || contained(commits.graph).length == 0}

{$t("doc.empty_container")}

{#if $cur_tab_doc_can_edit} - - {/if} + + {/if} {/if} \ No newline at end of file diff --git a/ng-app/src/apps/PostMdViewer.svelte b/ng-app/src/apps/PostMdViewer.svelte index 1342c12..1a4f779 100644 --- a/ng-app/src/apps/PostMdViewer.svelte +++ b/ng-app/src/apps/PostMdViewer.svelte @@ -53,6 +53,7 @@ let editor; let has_content = true; + let loading = true; async function setup() { try { @@ -120,9 +121,9 @@ Y.applyUpdate(ydoc, h.YXml, {local:true}) has_content = true; } + loading = false; } catch (e){ - console.log("in setup ") console.log(e) } } @@ -149,6 +150,7 @@ {#if !has_content} +
+
{/if} + {#if loading} +
+ + + + +

{$t("connectivity.loading")}...

+
+ {/if} +
diff --git a/ng-app/src/apps/ProseMirrorViewer.svelte b/ng-app/src/apps/ProseMirrorViewer.svelte index 29bb6af..1ade29c 100644 --- a/ng-app/src/apps/ProseMirrorViewer.svelte +++ b/ng-app/src/apps/ProseMirrorViewer.svelte @@ -33,6 +33,8 @@ const ydoc = new Y.Doc() const yxml = ydoc.getXmlFragment('ng') + let loading = true; + ydoc.on('destroy', async () => { commits.discrete?.deregisterOnUpdate(); }) @@ -55,7 +57,8 @@ for (const h of history) { Y.applyUpdate(ydoc, h.YXml, {local:true}) } - source = toHTML() + source = toHTML(); + loading = false; }); onDestroy(()=>{ @@ -69,6 +72,33 @@
+ {#if loading} +
+ + + + +

{$t("connectivity.loading")}...

+
+ {/if} + {#if source}
diff --git a/ng-app/src/apps/TextViewer.svelte b/ng-app/src/apps/TextViewer.svelte index 4f1dacb..fac3d41 100644 --- a/ng-app/src/apps/TextViewer.svelte +++ b/ng-app/src/apps/TextViewer.svelte @@ -45,7 +45,8 @@ let source = ""; const ydoc = new Y.Doc() - const ytext = ydoc.getText('ng') + const ytext = ydoc.getText('ng'); + let loading = true; ydoc.on('destroy', async () => { commits.discrete?.deregisterOnUpdate(); @@ -60,6 +61,7 @@ Y.applyUpdate(ydoc, h.YText, {local:true}) } source = ytext.toString() + loading = false; }); onDestroy(()=>{ @@ -72,6 +74,32 @@
+ {#if loading} +
+ + + + +

{$t("connectivity.loading")}...

+
+ {/if} {#if source} {#if $cur_tab_branch_class === "code:svelte"} diff --git a/ng-app/src/apps/YMapViewer.svelte b/ng-app/src/apps/YMapViewer.svelte index b55634b..7e5ba49 100644 --- a/ng-app/src/apps/YMapViewer.svelte +++ b/ng-app/src/apps/YMapViewer.svelte @@ -37,6 +37,7 @@ const ymap = ydoc.get('ng', crdt == "YMap" ? Y.Map : Y.Array) let editor; + let loading = true; let content = { text: undefined, @@ -102,6 +103,7 @@ }); editor.patch(operations); content.json = ymap.toJSON(); + loading = false; } }); @@ -117,7 +119,6 @@ for (const h of history) { Y.applyUpdate(ydoc, h[crdt], {local:true}) } - }); onDestroy(async ()=>{ @@ -126,6 +127,34 @@ }); + + {#if loading} +
+ + + + +

{$t("connectivity.loading")}...

+
+ {/if} +
diff --git a/ng-app/src/lib/Document.svelte b/ng-app/src/lib/Document.svelte index 194843e..902142f 100644 --- a/ng-app/src/lib/Document.svelte +++ b/ng-app/src/lib/Document.svelte @@ -90,19 +90,95 @@ {/if} {#if commits} {#await commits.load()} -
-

{$t("connectivity.loading")}...

+
+
+ + + + +

{$t("connectivity.loading")}...

+
{:then} - {#if $cur_app} {#await load_official_app($cur_app) then app} -
+
{/await} + {:else} +
+
+ + + + +

{$t("connectivity.loading")}...

+
+
{/if} {/await} + {:else} +
+
+ + + + +

{$t("connectivity.loading")}...

+
+
{/if}
diff --git a/ng-app/src/routes/WalletCreate.svelte b/ng-app/src/routes/WalletCreate.svelte index 46b8a8c..2953f3d 100644 --- a/ng-app/src/routes/WalletCreate.svelte +++ b/ng-app/src/routes/WalletCreate.svelte @@ -903,7 +903,7 @@ {@html $t("pages.wallet_create.broker_about.5")} -
  • +
  • - Q: I heard that with NextGraph there will be no more ToS to accept. Why then are there some ToS here?
    A: You are right that with NextGraph we can do without ToS, when the user is connecting to a self-hosted broker or to an NGbox. As those 2 options are not available yet, we only offer our public Broker Service Provider for now, which needs some ToS to be accepted. Very soon those 2 additional options will be available, but some users might still prefer using our brokers. In any case, the ToS here are minimal and with end-to-end encryption, your data is unreadable to us anyway.
    A: You are right that with NextGraph we can do without ToS, when the user is connecting to a self-hosted broker. As those 2 options are not available yet, we only offer our public Broker Service Provider for now, which needs some ToS to be accepted. Very soon those 2 additional options will be available, but some users might still prefer using our brokers. In any case, the ToS here are minimal and with end-to-end encryption, your data is unreadable to us anyway.