feat: show persisted investment data and sync state

Consume the provided resource-envelope API snapshot. Preserve financial snapshots during
refresh, observe synchronization without importing, and fence late responses across
account and connection changes.
This commit is contained in:
2026-09-26 21:22:49 +03:00
parent b987fd8e78
commit 4e5f564fa1
81 changed files with 4714 additions and 1420 deletions
+12 -3
View File
@@ -1,6 +1,7 @@
import { useDebouncedValue } from "@mantine/hooks";
import { useSearchParams } from "react-router";
import { useBondSearch } from "@/entities/bond";
import { useScreenSync } from "@/features/tbank-connection";
import { apiErrorCode } from "@/shared/api";
import { instrumentLogoUrl } from "@/shared/lib";
@@ -11,15 +12,23 @@ function useBondsPageVm() {
const query = params.get("q") ?? "";
const [debounced] = useDebouncedValue(query.trim(), SEARCH_DEBOUNCE_MS);
const result = useBondSearch(debounced);
const sync = useScreenSync({ screen: "bonds", query: debounced }, [result]);
const waiting = query.trim() !== debounced;
return {
query,
setQuery: (q: string) => setParams(q ? { q } : {}, { replace: true }),
loading: query.trim().length >= 2 && (waiting || result.isLoading),
error: result.isError,
loading:
query.trim().length >= 2 &&
(waiting ||
(!result.data &&
!result.isError &&
result.meta?.sync.state !== "failed")),
error: result.isError || sync.sourceError || sync.transportError,
refreshing: sync.refreshing,
partial: result.meta?.availability === "partial",
code: apiErrorCode(result.error),
retry: () => {
void result.refetch();
void sync.refresh();
},
ready: debounced.length >= 2 && !waiting && Boolean(result.data),
items: