From 9b0a1af95950630f65f0866cd5e0df23049e9da7 Mon Sep 17 00:00:00 2001
From: Sandwich <299465+dskvr@users.noreply.github.com>
Date: Mon, 10 Feb 2025 09:04:45 +0700
Subject: [PATCH] fix state change
---
.../components/data-view/DataViewRoot.svelte | 6 ++++--
.../shortcuts/RelayDataViewShortcut.svelte | 21 ++++++++++++-------
apps/gui/src/lib/managers/DataRegister.ts | 15 +++++++------
apps/gui/src/lib/stores/data-register.ts | 10 ++++-----
apps/gui/src/routes/+layout.svelte | 20 +++++++++++++++---
5 files changed, 46 insertions(+), 26 deletions(-)
diff --git a/apps/gui/src/lib/components/data-view/DataViewRoot.svelte b/apps/gui/src/lib/components/data-view/DataViewRoot.svelte
index 5a0c1bac..232cd947 100644
--- a/apps/gui/src/lib/components/data-view/DataViewRoot.svelte
+++ b/apps/gui/src/lib/components/data-view/DataViewRoot.svelte
@@ -1,5 +1,5 @@
@@ -129,7 +131,7 @@
{#if $activeView === 'map'}
{/if}
- {:else if $isBootstrapping}
+ {:else if $isBootstrapping && !$isSeeded}
bootstrapping
the application is still bootstrapping, please wait while seed data is populated.
diff --git a/apps/gui/src/lib/components/shortcuts/RelayDataViewShortcut.svelte b/apps/gui/src/lib/components/shortcuts/RelayDataViewShortcut.svelte
index 148c16f3..f8e11abc 100644
--- a/apps/gui/src/lib/components/shortcuts/RelayDataViewShortcut.svelte
+++ b/apps/gui/src/lib/components/shortcuts/RelayDataViewShortcut.svelte
@@ -1,4 +1,5 @@
{#if label}
@@ -198,13 +209,7 @@
{
- active.set(shortcut.title)
- if(shortcut?.payload){
- shortcut.hash = btoa(JSON.stringify(compress(shortcut.payload)))
- }
- onClick(`/relays#${shortcut.hash}`)
- }}
+ on:click={() => setActive(shortcut)}
class="{buttonClass} {$active === shortcut.title? buttonActiveClass: ''}"
>
{shortcut.title}
diff --git a/apps/gui/src/lib/managers/DataRegister.ts b/apps/gui/src/lib/managers/DataRegister.ts
index 73511e66..8951412e 100644
--- a/apps/gui/src/lib/managers/DataRegister.ts
+++ b/apps/gui/src/lib/managers/DataRegister.ts
@@ -18,6 +18,7 @@ export type DataRegisterComposite = {
key: string;
priority: number;
keys: string[];
+ fn?: DataRegisterFn;
condition?: DataRegisterCondition;
onComplete?: DataRegisterFn;
ignoreConditions?: Record;
@@ -241,19 +242,17 @@ export class DataRegister {
}
private async executeComposite(args: DataRegisterCompositeExecutorArguments = { key: '', params: {} }) {
- // console.log('executeComposite', args)
const { key: compositeKey, ignoreCondition: compositeIgnoreCondition, params:paramsMap } = args;
const shouldRun = await this.testCondition(compositeKey, compositeIgnoreCondition, true);
- if (!shouldRun) {
- //console.log('executeComposite', 'condition failed', compositeKey)
- return;
- }
+ if (!shouldRun) return;
const composite = this._composite.get(compositeKey)!;
- // composite.keys.forEach( (childKey) => this._busy.set(childKey, true) );
- //
+ const { fn } = composite;
+ if(fn && typeof fn === 'function') {
+ const params: any[] = this.extractParams(compositeKey, paramsMap);
+ await fn(params)
+ }
const results = new Map()
for (const childKey of composite.keys) {
- // console.log('executeComposite', 'childKey', childKey)
if (this.busy(childKey)) continue;
const params: any[] = this.extractParams(childKey, paramsMap);
this.localStorageLoadTimestamp(childKey, params)
diff --git a/apps/gui/src/lib/stores/data-register.ts b/apps/gui/src/lib/stores/data-register.ts
index a46db628..20e7cb99 100644
--- a/apps/gui/src/lib/stores/data-register.ts
+++ b/apps/gui/src/lib/stores/data-register.ts
@@ -171,10 +171,10 @@ export const dataRegisterInit = async () => {
'validate:nip11s'
],
priority: -10,
- condition: async () => {
- isBootstrapping.set(true)
- return true;
- },
+ // fn: async () => {
+ // isBootstrapping.set(true)
+ // return true;
+ // },
onComplete: async () => {
isBootstrapping.set(false)
isBootstrapped.set(true)
@@ -195,7 +195,7 @@ export const dataRegisterInit = async () => {
],
// condition: async () => !get(doBootstrap),
priority: -10,
- condition: async () => {
+ fn: async () => {
isBootstrapping.set(true)
return true;
},
diff --git a/apps/gui/src/routes/+layout.svelte b/apps/gui/src/routes/+layout.svelte
index acd9ce26..fdf1aef4 100755
--- a/apps/gui/src/routes/+layout.svelte
+++ b/apps/gui/src/routes/+layout.svelte
@@ -243,7 +243,21 @@
$: percentCompleted = percentModulesLoaded * 0.5 + (numMonitorsSynced*10) + (relayChecksSynced? 20: 0);
let loadingThresholdPassed = false;
- setTimeout(() => loadingThresholdPassed = true, 200 )
+ let loadingThresholdTimeout: ReturnType;
+
+ $: {
+ if($navigating?.to){
+ console.log('navigating to:', $navigating.to)
+ clearTimeout(loadingThresholdTimeout)
+ loadingThresholdPassed = false
+ }
+ if($navigating?.from){
+ console.log('navigating from:', $navigating.from)
+ loadingThresholdTimeout = setTimeout(() => loadingThresholdPassed = true, 1000 )
+ }
+ }
+ setTimeout(() => loadingThresholdPassed = true, 1000 )
+
$: loading = loadingThresholdPassed && (!isReady || !loadedEnough);
@@ -254,7 +268,7 @@ loadedEnough: {loadedEnough} -->
{#if $unsupported}
-
Unsupported
+
Unsupported
This version of nostr.watch does not support mobile devices.
{:else}
@@ -262,7 +276,7 @@ loadedEnough: {loadedEnough} -->
{:else if loading && hasBeenBootstrapped()}
-
booting.
+
loading.
[{$tabState}]
{/if}