Skip to content

Commit

Permalink
fix state change
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Feb 10, 2025
1 parent a424104 commit 9b0a1af
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 26 deletions.
6 changes: 4 additions & 2 deletions apps/gui/src/lib/components/data-view/DataViewRoot.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { isBootstrapping } from "$stores/app";
import { isBootstrapping, isSeeded } from "$stores/app";
import { onMount } from 'svelte';
import { get, writable, derived, type Writable, type Readable, readable } from 'svelte/store';
import * as Resizable from '$lib/components/ui/resizable';
Expand Down Expand Up @@ -110,6 +110,8 @@
$: activeFilters = Object.keys($filters || {}).length
export let activeView: Writable<'table' | 'grid' | 'map'>;
let loading = false
</script>

<DataViewSelector {enabledViews} bind:activeView />
Expand All @@ -129,7 +131,7 @@
{#if $activeView === 'map'}
<MapRoot data={justData} {filters} />
{/if}
{:else if $isBootstrapping}
{:else if $isBootstrapping && !$isSeeded}
<div class="flex items-center justify-center h-full">
<span class="text-7xl">bootstrapping</span>
<span class="text-xl">the application is still bootstrapping, please wait while seed data is populated.</span>
Expand Down
21 changes: 13 additions & 8 deletions apps/gui/src/lib/components/shortcuts/RelayDataViewShortcut.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { page } from "$app/stores";
import { goto } from "$app/navigation";
import Page from "$routes/+page.svelte";
import Badge from "$ui/badge/badge.svelte";
Expand Down Expand Up @@ -185,8 +186,18 @@
}
onMount( () => {
if(!window.location.hash && $page.url.pathname === "/relays"){
setActive(shortcuts[0]);
}
})
const setActive = (shortcut: any) => {
active.set(shortcut.title)
if(shortcut?.payload){
shortcut.hash = btoa(JSON.stringify(compress(shortcut.payload)))
}
onClick(`/relays#${shortcut.hash}`)
}
</script>
<div class="leading-9 {className}">
{#if label}
Expand All @@ -198,13 +209,7 @@
<Button
size="small"
variant={buttonVariant}
on:click={() => {
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}
Expand Down
15 changes: 7 additions & 8 deletions apps/gui/src/lib/managers/DataRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type DataRegisterComposite = {
key: string;
priority: number;
keys: string[];
fn?: DataRegisterFn;
condition?: DataRegisterCondition;
onComplete?: DataRegisterFn;
ignoreConditions?: Record<string, boolean>;
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions apps/gui/src/lib/stores/data-register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -195,7 +195,7 @@ export const dataRegisterInit = async () => {
],
// condition: async () => !get(doBootstrap),
priority: -10,
condition: async () => {
fn: async () => {
isBootstrapping.set(true)
return true;
},
Expand Down
20 changes: 17 additions & 3 deletions apps/gui/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,21 @@
$: percentCompleted = percentModulesLoaded * 0.5 + (numMonitorsSynced*10) + (relayChecksSynced? 20: 0);
let loadingThresholdPassed = false;
setTimeout(() => loadingThresholdPassed = true, 200 )
let loadingThresholdTimeout: ReturnType<typeof setTimeout>;
$: {
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);
</script>

Expand All @@ -254,15 +268,15 @@ loadedEnough: {loadedEnough} <br /> -->

{#if $unsupported}
<div class="flex flex-col items-center justify-center h-screen px-4">
<div class="text-7xl">Unsupported</div>
<div class="text-3xl">Unsupported</div>
<div class="text-xs opacity-30">This version of nostr.watch does not support mobile devices.</div>
</div>
{:else}
{#if loading && !hasBeenBootstrapped()}
<BootstrapLoading {isReady} {monitorsSynced} {relayChecksSynced} {percentCompleted} />
{:else if loading && hasBeenBootstrapped()}
<div class="flex flex-col items-center justify-center h-screen px-4">
<div class="text-7xl">booting.</div>
<div class="text-7xl">loading.</div>
<div class="text-xs opacity-30">[{$tabState}]</div>
</div>
{/if}
Expand Down

0 comments on commit 9b0a1af

Please sign in to comment.