Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): chat view no longer renders twice per update #20847

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/20847/headmerged by juliusmarminge View on GitHub

Showing 17 changed files with 73 additions and 61 deletions (loading 14).

x
0 of 17 viewed, 17 left
10 additions and 8 deletionsapps/web/src/components/chat/useAutoBalanceUpdateBanner.tsxModified
View file
@@ -1,10 +1,10 @@
import { useAtomValue } from "@effect/atom-react";
import type { ServerUpdateState } from "@t3tools/client-runtime/state/server";
-import { Atom } from "effect/reactivity";
import { useState } from "react";
​
+import { environmentIdsKey } from "~/state/environmentAtomList";
import type { EnvironmentPresentation } from "~/state/environments";
-import { serverEnvironment } from "~/state/server";
+import { environmentUpdateStatesAtom } from "~/state/server";
import {
buildVersionMismatchDismissalKey,
dismissServerUpdateFailure,
@@ -29,13 +29,15 @@
export function useAutoBalanceUpdateBanner(
environments: readonly EnvironmentPresentation[],
): ComposerBannerStackItem | null {
- const statesAtom = Atom.make((get) =>
- environments.map((environment) => ({
- environment,
- state: get(serverEnvironment.updateStateAtom(environment.environmentId)),
- })),
+ const updateStates = useAtomValue(
+ environmentUpdateStatesAtom(
+ environmentIdsKey(environments.map(({ environmentId }) => environmentId)),
+ ),
);
- const states = useAtomValue(statesAtom);
+ const states = environments.flatMap((environment, index) => {
+ const state = updateStates[index];