fix(console): reject edits of stale routes

A conflict reload can leave an older route editor open.
Compare its original value before saving so it cannot overwrite
the newly loaded route.
This commit is contained in:
翅膀 committed 2026-10-23 23:23:45 +08:00
1 parent 6eb9cbab4e
commit 4fae01453c
2 files changed
+10

No files matched your search

+7
View File
@@ -968,6 +968,13 @@ async function onSave(route: Route): Promise<void> {
try {
let next: Route[];
if (editing.value) {
// The route must still be the one the editor opened: a version changed
// by someone else meanwhile would otherwise be overwritten silently.
const latest = groupRoutes.value.find((r) => r.id === editing.value!.id);
if (!latest || JSON.stringify(latest) !== JSON.stringify(editing.value)) {
push(t("toast.routeChanged"), "bad");
return;
}
next = groupRoutes.value.map((r) => (r.id === editing.value!.id ? route : r));
} else {
if (groupRoutes.value.some((r) => r.id === route.id)) {