diff --git a/src/components/Workspace/workspace.state.ts b/src/components/Workspace/workspace.state.ts index 8769c82..42133cf 100644 --- a/src/components/Workspace/workspace.state.ts +++ b/src/components/Workspace/workspace.state.ts @@ -199,6 +199,10 @@ export const workspaceEntryCtxOrAdd$ = ( pushWorkspaceEntry(entryData) }), map((data) => data.context!), + catchError((ex) => { + console.error(ex) + return [null] + }), ) }), ) diff --git a/src/pages/Storage/StorageSubscriptions.tsx b/src/pages/Storage/StorageSubscriptions.tsx index 066a897..0363b2f 100644 --- a/src/pages/Storage/StorageSubscriptions.tsx +++ b/src/pages/Storage/StorageSubscriptions.tsx @@ -81,6 +81,8 @@ const StorageSubscriptionBox: FC<{ id: string }> = ({ id }) => { return case "values": return + case "error": + return
Error: {status.value}
} } diff --git a/src/pages/Storage/StorageWorkspaceEntry.tsx b/src/pages/Storage/StorageWorkspaceEntry.tsx index bc9885e..c2800c7 100644 --- a/src/pages/Storage/StorageWorkspaceEntry.tsx +++ b/src/pages/Storage/StorageWorkspaceEntry.tsx @@ -24,6 +24,10 @@ export const StorageWorkspaceEntry: FC<{ ) } + if (status.type === "error") { + return

Error: {status.value}

+ } + if (!status.value.length) return null const result = status.value[status.value.length - 1].result diff --git a/src/pages/Storage/storage.state.ts b/src/pages/Storage/storage.state.ts index cb2747e..459a755 100644 --- a/src/pages/Storage/storage.state.ts +++ b/src/pages/Storage/storage.state.ts @@ -312,17 +312,44 @@ export const storageSubscriptionToWorkspaceEntry = async ({ .buildStorage(pallet, item) .value.dec(value.value), }), - ) - : getValues$(at, isEntries, keyCodec).pipe( - map((v) => Enum("values", v)), - takeUntil(selectedChainChanged$), - shareReplay({ - bufferSize: 1, - refCount: true, + ).pipe( + catchError((ex) => { + console.error(ex) + return [Enum("error", String(ex))] }), ) - const status$: StorageEntryContext["status$"] = state(value$, Enum("loading")) - const completed$ = state(value$.pipe(ignoreElements(), endWith(true)), false) + : blockHash + ? at(blockHash).pipe( + map((v) => + Enum("value", { + blockHash, + ...v, + }), + ), + catchError((ex) => { + console.error(ex) + return [Enum("error", String(ex))] + }), + ) + : getValues$(at, isEntries, keyCodec).pipe( + map((v) => Enum("values", v)), + ) + const sharedValue$ = value$.pipe( + takeUntil(selectedChainChanged$), + shareReplay({ + bufferSize: 1, + refCount: true, + }), + ) + + const status$: StorageEntryContext["status$"] = state( + sharedValue$, + Enum("loading"), + ) + const completed$ = state( + sharedValue$.pipe(ignoreElements(), endWith(true)), + false, + ) const context: StorageEntryContext = { id, @@ -387,6 +414,7 @@ export type StorageEntryContext = { } // For subscriptions, adds one new value on every change values: Array + error: string }> > }