mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 11:43:57 +08:00
fix(pi): refresh desired takeover state after failures
This commit is contained in:
@@ -45,21 +45,21 @@ export function ProxyToggle({ className, activeApp }: ProxyToggleProps) {
|
||||
defaultValue: `${appLabel} routing is desired but currently degraded; CC Switch will retry it`,
|
||||
})
|
||||
: takeoverEnabled
|
||||
? isRunning
|
||||
? t("proxy.takeover.tooltip.active", {
|
||||
? isRunning
|
||||
? t("proxy.takeover.tooltip.active", {
|
||||
appLabel,
|
||||
address: status?.address,
|
||||
port: status?.port,
|
||||
defaultValue: `${appLabel} 已接管 - ${status?.address}:${status?.port}\n切换该应用供应商为热切换`,
|
||||
})
|
||||
: t("proxy.takeover.tooltip.broken", {
|
||||
appLabel,
|
||||
defaultValue: `${appLabel} 已接管,但代理服务未运行`,
|
||||
})
|
||||
: t("proxy.takeover.tooltip.inactive", {
|
||||
appLabel,
|
||||
address: status?.address,
|
||||
port: status?.port,
|
||||
defaultValue: `${appLabel} 已接管 - ${status?.address}:${status?.port}\n切换该应用供应商为热切换`,
|
||||
})
|
||||
: t("proxy.takeover.tooltip.broken", {
|
||||
appLabel,
|
||||
defaultValue: `${appLabel} 已接管,但代理服务未运行`,
|
||||
})
|
||||
: t("proxy.takeover.tooltip.inactive", {
|
||||
appLabel,
|
||||
defaultValue: `接管 ${appLabel} 的 Live 配置,让该应用请求走本地代理`,
|
||||
});
|
||||
defaultValue: `接管 ${appLabel} 的 Live 配置,让该应用请求走本地代理`,
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -129,9 +129,6 @@ export function useProxyStatus() {
|
||||
}),
|
||||
{ closeButton: true },
|
||||
);
|
||||
|
||||
queryClient.invalidateQueries({ queryKey: proxyKeys.status });
|
||||
queryClient.invalidateQueries({ queryKey: proxyKeys.takeoverStatus });
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
const detail =
|
||||
@@ -144,6 +141,20 @@ export function useProxyStatus() {
|
||||
}),
|
||||
);
|
||||
},
|
||||
// Pi persists desired takeover before attempting listener/runtime work.
|
||||
// A rejected IPC can therefore still have changed authoritative state.
|
||||
onSettled: async () => {
|
||||
await Promise.all([
|
||||
queryClient.refetchQueries({
|
||||
queryKey: proxyKeys.status,
|
||||
type: "active",
|
||||
}),
|
||||
queryClient.refetchQueries({
|
||||
queryKey: proxyKeys.takeoverStatus,
|
||||
type: "active",
|
||||
}),
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user