refactor: clarify frontend model ownership
This commit is contained in:
@@ -6,18 +6,15 @@ import {
|
||||
apiErrorCode,
|
||||
apiQueryClient,
|
||||
invalidateResourceAccess,
|
||||
type InvestmentResourceMeta,
|
||||
isApiErrorCode,
|
||||
type paths,
|
||||
useAuthenticatedQueries,
|
||||
} from "@/shared/api";
|
||||
|
||||
import { type InvestmentScreen, useTbankSync } from "./sync";
|
||||
|
||||
type ResourceMeta
|
||||
= paths["/api/v1/tbank-sync/{id}"]["get"]["responses"][200]["content"]["application/json"]["resources"][number];
|
||||
|
||||
type ScreenResource = {
|
||||
meta?: ResourceMeta;
|
||||
meta?: InvestmentResourceMeta;
|
||||
observe: (version?: string) => Promise<unknown>;
|
||||
queryKey: QueryKey;
|
||||
transport: {
|
||||
@@ -34,7 +31,7 @@ const STATUS_INTERVAL_MS = 1000;
|
||||
|
||||
function observeResource(
|
||||
resource: ScreenResource,
|
||||
latest: Map<string, ResourceMeta>,
|
||||
latest: Map<string, InvestmentResourceMeta>,
|
||||
completedId: string | undefined,
|
||||
observed: Map<string, string>,
|
||||
) {
|
||||
@@ -143,7 +140,7 @@ function useScreenSync(scope: InvestmentScreen, resources: ScreenResource[]) {
|
||||
invalidateResourceAccess(client, "brokerage", status.error);
|
||||
}
|
||||
|
||||
const latest = new Map<string, ResourceMeta>();
|
||||
const latest = new Map<string, InvestmentResourceMeta>();
|
||||
|
||||
const orderedStatuses = statuses.toSorted(
|
||||
(a, b) => a.dataUpdatedAt - b.dataUpdatedAt,
|
||||
|
||||
Reference in New Issue
Block a user