mirror of
https://github.com/block/buzz.git
synced 2026-11-02 23:41:08 +00:00
Co-authored-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Tyler Longwell <tlongwell@block.xyz> Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
29 lines
900 B
TypeScript
29 lines
900 B
TypeScript
import { useQueryClient } from "@tanstack/react-query";
|
|
import * as React from "react";
|
|
|
|
import { managedAgentRuntimesQueryKey } from "@/features/agents/managedAgentRuntimeHooks";
|
|
import { reconcileManagedAgentRuntimes } from "@/shared/api/tauriManagedAgents";
|
|
|
|
export function useManagedAgentRuntimeReconciliation(
|
|
communities: readonly { relayUrl: string }[],
|
|
): void {
|
|
const queryClient = useQueryClient();
|
|
const reconciled = React.useRef(false);
|
|
|
|
React.useEffect(() => {
|
|
if (reconciled.current) return;
|
|
reconciled.current = true;
|
|
|
|
void reconcileManagedAgentRuntimes(communities)
|
|
.then((runtimes) => {
|
|
queryClient.setQueryData(managedAgentRuntimesQueryKey, runtimes);
|
|
})
|
|
.catch((error) => {
|
|
console.warn(
|
|
"[managed-agent-runtimes] startup reconcile failed:",
|
|
error,
|
|
);
|
|
});
|
|
}, [communities, queryClient]);
|
|
}
|