refactor: enforce frontend view model boundaries
This commit is contained in:
@@ -9,6 +9,7 @@ import { instrumentLogoUrl } from "@/shared/lib";
|
||||
const SEARCH_DEBOUNCE_MS = 300;
|
||||
|
||||
type BondsPageVm = ReturnType<typeof useBondsPageVm>;
|
||||
|
||||
function useBondsPageVm() {
|
||||
const [parameters, setParameters] = useSearchParams();
|
||||
const query = parameters.get("q") ?? "";
|
||||
@@ -17,6 +18,7 @@ function useBondsPageVm() {
|
||||
const sync = useScreenSync({ query: debounced, screen: "bonds" }, [result]);
|
||||
const canSearch = query.trim().length >= MIN_BOND_SEARCH_LENGTH;
|
||||
const isWaiting = query.trim() !== debounced;
|
||||
|
||||
return {
|
||||
canSearch,
|
||||
code: apiErrorCode(result.error),
|
||||
@@ -35,7 +37,10 @@ function useBondsPageVm() {
|
||||
&& result.meta?.sync.state !== "failed")),
|
||||
partial: result.meta?.availability === "partial",
|
||||
query,
|
||||
ready: debounced.length >= MIN_BOND_SEARCH_LENGTH && !isWaiting && Boolean(result.data),
|
||||
ready:
|
||||
debounced.length >= MIN_BOND_SEARCH_LENGTH
|
||||
&& !isWaiting
|
||||
&& Boolean(result.data),
|
||||
refreshing: sync.refreshing,
|
||||
retry: () => {
|
||||
void sync.retry();
|
||||
|
||||
Reference in New Issue
Block a user