From 4820e930177e354cac02c66cd2c9f936eccf3772 Mon Sep 17 00:00:00 2001 From: Victor Oliva Date: Fri, 14 Nov 2025 12:06:02 -0300 Subject: [PATCH] fix uncaught SUSPENSE errors, reset selected entry if it doesn't exist --- src/pages/Explorer/block.state.ts | 6 +++--- src/pages/Storage/BlockPicker.tsx | 22 +++++++++++++++++----- src/pages/Storage/Storage.tsx | 2 +- src/pages/Storage/storage.state.ts | 18 +++++++++--------- src/state/polkahub.ts | 2 ++ 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/pages/Explorer/block.state.ts b/src/pages/Explorer/block.state.ts index 0aa89d9..65a9831 100644 --- a/src/pages/Explorer/block.state.ts +++ b/src/pages/Explorer/block.state.ts @@ -1,7 +1,7 @@ import { chopsticksInstance$ } from "@/chopsticks/chopsticks" import { chainClient$, client$ } from "@/state/chains/chain.state" import { SystemEvent } from "@polkadot-api/observable-client" -import { state } from "@react-rxjs/core" +import { liftSuspense, state } from "@react-rxjs/core" import { combineKeys, partitionByKey } from "@react-rxjs/utils" import { FixedSizeBinary, HexString, PolkadotClient } from "polkadot-api" import { @@ -77,7 +77,7 @@ const finalizedBlocks$ = state( }), ), ) -finalizedBlocks$.subscribe() +finalizedBlocks$.pipe(liftSuspense()).subscribe() export const [blockInfo$, recordedBlocks$] = partitionByKey( client$.pipe(switchMap((client) => client.blocks$)), @@ -242,7 +242,7 @@ export const inMemoryBlocks$ = state( blockInfo$(key).pipe(startWith(null)), ).pipe(repeat()), ) -inMemoryBlocks$.subscribe() +inMemoryBlocks$.pipe(liftSuspense()).subscribe() export const blockHash$ = (hashOrHeight: string) => hashOrHeight.length > 63 diff --git a/src/pages/Storage/BlockPicker.tsx b/src/pages/Storage/BlockPicker.tsx index 4c82a1d..3405e34 100644 --- a/src/pages/Storage/BlockPicker.tsx +++ b/src/pages/Storage/BlockPicker.tsx @@ -2,7 +2,12 @@ import { Spinner } from "@/components/Icons" import { runtimeCtx$, runtimeCtxAt$ } from "@/state/chains/chain.state" import { RuntimeContext } from "@polkadot-api/observable-client" import { Input } from "@polkahub/ui-components" -import { state, useStateObservable } from "@react-rxjs/core" +import { + liftSuspense, + state, + SUSPENSE, + useStateObservable, +} from "@react-rxjs/core" import { createSignal } from "@react-rxjs/utils" import { Check, X } from "lucide-react" import { @@ -36,10 +41,17 @@ const loadedCtx$ = state( ) return inner$.pipe( - map((value) => ({ - type: "success" as const, - value, - })), + liftSuspense(), + map((value) => + value === SUSPENSE + ? { + type: "loading" as const, + } + : { + type: "success" as const, + value, + }, + ), catchError((value) => [ { type: "error" as const, diff --git a/src/pages/Storage/Storage.tsx b/src/pages/Storage/Storage.tsx index 050e52c..a79ccd1 100644 --- a/src/pages/Storage/Storage.tsx +++ b/src/pages/Storage/Storage.tsx @@ -57,7 +57,7 @@ export const Storage = withSubscribe( }))} /> - {partialEntry.pallet && ( + {partialEntry.pallet && entries[partialEntry.pallet] && (