Refresh node load in location picker without page reload
Invalidate available-inbounds when the create dialog opens, after a config is created or revoked, and on realtime config status changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bb5e59904f
commit
ddd8a36c64
3 files changed
+13
-1
No files matched your search
@@ -49,6 +49,7 @@ export function ConfigCard({ config }: { config: VpnConfigDto }) {
|
||||
toast.success(t('configs.revoked'))
|
||||
setDetailsOpen(false)
|
||||
await queryClient.invalidateQueries({ queryKey: ['my-configs'] })
|
||||
await queryClient.invalidateQueries({ queryKey: ['available-inbounds'] })
|
||||
},
|
||||
onError: () => toast.error(t('auth.genericError')),
|
||||
})
|
||||
|
||||
@@ -59,6 +59,8 @@ export function CreateConfigDialog({ inbounds }: { inbounds: AvailableInboundDto
|
||||
onSuccess: async () => {
|
||||
toast.success(t('configs.created'))
|
||||
await queryClient.invalidateQueries({ queryKey: ['my-configs'] })
|
||||
// Новый конфиг меняет загрузку ноды (AvailableInboundDto.loadPercent/nodeConfigCount).
|
||||
await queryClient.invalidateQueries({ queryKey: ['available-inbounds'] })
|
||||
setOpen(false)
|
||||
setInboundId('')
|
||||
setLabel('')
|
||||
@@ -80,7 +82,14 @@ export function CreateConfigDialog({ inbounds }: { inbounds: AvailableInboundDto
|
||||
})
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<Dialog
|
||||
open={open}
|
||||
onOpenChange={(next) => {
|
||||
// Загрузку нод меняют и другие пользователи — при каждом открытии берём свежую.
|
||||
if (next) void queryClient.invalidateQueries({ queryKey: ['available-inbounds'] })
|
||||
setOpen(next)
|
||||
}}
|
||||
>
|
||||
<DialogTrigger asChild>
|
||||
<Button>
|
||||
<Plus className="h-4 w-4" />
|
||||
|
||||
@@ -44,6 +44,8 @@ export function RealtimeProvider({ children }: { children: React.ReactNode }) {
|
||||
? { ...prev, configs: prev.configs.map((c) => (c.id === payload.configId ? { ...c, status: payload.status } : c)) }
|
||||
: prev,
|
||||
)
|
||||
// Загрузка нод считается по Active-конфигам — смена статуса её меняет.
|
||||
void queryClient.invalidateQueries({ queryKey: ['available-inbounds'] })
|
||||
}
|
||||
|
||||
const onUserActivated = (_payload: UserActivated) => {
|
||||
|
||||
Reference in new issue
Block a user