fix(ui): проверять подтверждение восстановления WireGuard

This commit is contained in:
Denozordec committed 2026-09-29 08:43:31 +07:00
1 parent 425a77a1ca
commit 221d6db10c
5 files changed
+51 -6

No files matched your search

+6 -2
View File
@@ -211,6 +211,7 @@ function WireGuardPageContent({ selectedServerId, selectedInterfaceId, allInterf
const [historyOpen, setHistoryOpen] = useState(false)
const [revisions, setRevisions] = useState<ConfigRevisionDto[]>([])
const [historyLoading, setHistoryLoading] = useState(false)
const restoreLock = useRef(false)
const [historyRestoring, setHistoryRestoring] = useState(false)
const [liveExport, setLiveExport] = useState<{
rsc?: string
@@ -287,20 +288,23 @@ function WireGuardPageContent({ selectedServerId, selectedInterfaceId, allInterf
}, [isLive, historyServerId, backendUrl])
const restoreRevision = useCallback(async (id: string) => {
if (!isLive || !historyServerId) return
if (!isLive || !historyServerId || restoreLock.current) return
restoreLock.current = true
setHistoryRestoring(true)
try {
await requestJson(
const result = await requestJson<{ ok: boolean }>(
backendUrl,
`/api/wireguard/revisions/${encodeURIComponent(id)}/restore`,
{ method: "POST", body: JSON.stringify({ serverId: historyServerId }) },
)
if (result?.ok !== true) throw new Error("Сервер не подтвердил восстановление")
toast.success("Версия применена на роутер")
await loadLive()
await loadRevisions()
} catch (err) {
toast.error("Не удалось откатить", { description: String(err) })
} finally {
restoreLock.current = false
setHistoryRestoring(false)
}
}, [isLive, historyServerId, backendUrl, loadLive, loadRevisions])