Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 20 additions & 29 deletions apps/web/src/components/ProviderUpdatePrimaryNotification.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useNavigate } from "@tanstack/react-router";
import { useAtomValue } from "@effect/atom-react";
import { DownloadIcon } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef } from "react";
import { useEffect, useRef } from "react";
import {
AuthProvidersManageScope,
type ServerProvider,
Expand Down Expand Up @@ -126,36 +126,27 @@ export function ProviderUpdatePrimaryNotification() {
};
}, []);

const updateProviders = useMemo(() => collectProviderUpdateCandidates(providers), [providers]);
const notificationKey = useMemo(
() => providerUpdateNotificationKey(updateProviders),
[updateProviders],
);
const oneClickProviders = useMemo(
() =>
updateProviders.filter((provider) => canOneClickUpdateProviderCandidate(provider, providers)),
[providers, updateProviders],
const updateProviders = collectProviderUpdateCandidates(providers);
const notificationKey = providerUpdateNotificationKey(updateProviders);
const oneClickProviders = updateProviders.filter((provider) =>
canOneClickUpdateProviderCandidate(provider, providers),
);

const openProviderSettings = useCallback(
(toastId?: ProviderUpdateToastId) => {
const activeToast = activeToastRef.current;
if (toastId !== undefined) {
toastManager.close(toastId);
} else if (activeToast?.kind === "prompt") {
toastManager.close(activeToast.toastId);
}
if (
activeToast &&
(toastId === undefined ||
(activeToast.kind === "prompt" && activeToast.toastId === toastId))
) {
activeToastRef.current = null;
}
void navigate({ to: "/settings/providers" });
},
[navigate],
);
const openProviderSettings = (toastId?: ProviderUpdateToastId) => {
const activeToast = activeToastRef.current;
if (toastId !== undefined) {
toastManager.close(toastId);
} else if (activeToast?.kind === "prompt") {
toastManager.close(activeToast.toastId);
}
if (
activeToast &&
(toastId === undefined || (activeToast.kind === "prompt" && activeToast.toastId === toastId))
) {
activeToastRef.current = null;
}
void navigate({ to: "/settings/providers" });
};

useEffect(() => {
const activeToast = activeToastRef.current;
Expand Down
Loading