From a0e52ab4658b87a76c04da3e202f2c3cb0e8e9ed Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Thu, 12 Oct 2023 20:19:40 +0300 Subject: [PATCH] open popup for external links on tauri --- ng-app/src/routes/User.svelte | 62 +++++++++++++++--------- ng-app/src/routes/WalletCreate.svelte | 67 ++++++++++++++------------ ngaccount/web/src/routes/Create.svelte | 20 +++++--- p2p-net/src/broker.rs | 2 + 4 files changed, 87 insertions(+), 64 deletions(-) diff --git a/ng-app/src/routes/User.svelte b/ng-app/src/routes/User.svelte index 5088157..ad9ccda 100644 --- a/ng-app/src/routes/User.svelte +++ b/ng-app/src/routes/User.svelte @@ -78,6 +78,20 @@ $: personal_site = $active_wallet?.wallet?.V0.personal_site_id; $: personal_site_status = $connections[personal_site]; + + const displayPopup = async (url, title) => { + if (!tauri_platform || tauri_platform == "android") { + window.open(url, "_blank").focus(); + } else { + await ng.open_window(url, "viewer", title); + } + }; + const donate = async () => { + await displayPopup("https://nextgraph.org/donate", "Support NextGraph"); + }; + const about = async () => { + await displayPopup("https://nextgraph.org", "About NextGraph"); + }; @@ -219,32 +233,32 @@ {/if} - - - - - - + Donate to NextGraph + + +
  • - - - - + + About NextGraph +
  • +
  • diff --git a/ng-app/src/routes/WalletCreate.svelte b/ng-app/src/routes/WalletCreate.svelte index ffaaeb9..8a3a504 100644 --- a/ng-app/src/routes/WalletCreate.svelte +++ b/ng-app/src/routes/WalletCreate.svelte @@ -256,30 +256,21 @@ } } - async function getWallet() { - const opts = { - method: "get", - }; - const response = await fetch( - api_url + "bootstrap/I8tuoVE-LRH1wuWQpDBPivlSX8Wle39uHSL576BTxsk", - opts - ); - const result = await response.json(); - console.log("Result:", result); - } + // async function getWallet() { + // const opts = { + // method: "get", + // }; + // const response = await fetch( + // api_url + "bootstrap/I8tuoVE-LRH1wuWQpDBPivlSX8Wle39uHSL576BTxsk", + // opts + // ); + // const result = await response.json(); + // console.log("Result:", result); + // } onMount(async () => await bootstrap()); ready = false; - // { - // user: { - // Ed25519PubKey: [ - // 141, 114, 111, 29, 59, 133, 182, 172, 177, 211, 238, 224, 62, 208, 206, - // 18, 226, 219, 118, 229, 184, 76, 204, 29, 194, 228, 248, 186, 15, 113, - // 125, 119, - // ], - // }, - // }; const unsub_register = () => { if (unsub_register_accepted) unsub_register_accepted(); @@ -375,19 +366,25 @@ }; const enterINVITE = (event) => {}; const enterQRcode = (event) => {}; - const displayNGbox = async (event) => { + + const displayPopup = async (url, title) => { if (!tauri_platform || tauri_platform == "android") { - window.open(LINK_NG_BOX, "_blank").focus(); + window.open(url, "_blank").focus(); } else { - await ng.open_window(LINK_NG_BOX, "viewer", "Own your NG-Box"); + await ng.open_window(url, "viewer", title); } }; + const displayNGbox = async (event) => { + await displayPopup(LINK_NG_BOX, "Own your NG-Box"); + }; const displaySelfHost = async (event) => { - if (!tauri_platform || tauri_platform == "android") { - window.open(LINK_SELF_HOST, "_blank").focus(); - } else { - await ng.open_window(LINK_SELF_HOST, "viewer", "Self-host a broker"); - } + await displayPopup(LINK_SELF_HOST, "Self-host a broker"); + }; + const tos = async () => { + await displayPopup( + "https://nextgraph.one/#/tos", + "Terms of Service NextGraph.one" + ); }; @@ -1364,8 +1361,11 @@ Only you will be able to download it with a special link. You would have to keep this link safely though. By selecting this option, you agree to the - Terms of Service of our cloudTerms of Service of our cloud.
    Terms of Service of our cloudTerms of Service of our cloud.
    You can delete your account with us at any time by going to the - link account.{domain}/#/deleteaccount.{domain}/#/delete or by entering in your NextGraph application and selecting the menu, then Accounts, then under broker "delete registration" @@ -331,12 +332,15 @@ Registration is free of charge. And it would be very nice of you if you wanted to donate a small amount to help us cover the - fees we have to pay for operating the servers. Here is the - donation link: https://nextgraph.org/donate + fees we have to pay for operating the servers. {#if !window.__TAURI__} + Here is the donation link: https://nextgraph.org/donate{:else} + You will find the link to donate in your app, by clicking on + the logo of NextGraph on the top-left corner. + {/if}
  • {#if !window.__TAURI__} diff --git a/p2p-net/src/broker.rs b/p2p-net/src/broker.rs index 725e7d1..4dfead3 100644 --- a/p2p-net/src/broker.rs +++ b/p2p-net/src/broker.rs @@ -850,6 +850,8 @@ impl<'a> Broker<'a> { // log_debug!("SOCKET RECONNECTION {:?} {:?}", result, &remote_peer_id); // TODO: deal with error and incremental backoff + // TODO: incremental reconnections: after 5sec, +10sec, +20sec, +30sec + // if all attempts fail : if let Some(user) = config.get_user() { disconnections_sender.send(user.to_string()).await;