mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 11:25:56 +00:00
- Add UnsavedChangesGuard modal (Save/Discard/Cancel) when navigating between tabs - Wire guard into ModulesPage and SettingsPage with floating action bar - Implement crash parser and explanation engine in coa-core - Expose list_crashes Tauri command and CrashItem API - Add auto-restart on unexpected server crash with crash loop protection - Add crash counter badge and CrashHistoryModal with human-readable explanations and full crashlogs - Support all 6 locales (en, ru, de, fr, es, zh)
33 lines
763 B
TypeScript
33 lines
763 B
TypeScript
import { useState } from "react";
|
|
|
|
const key = (id: string) => `coa-auto-restart-on-crash:${id}`;
|
|
const fallback = () => false;
|
|
|
|
export function autoRestartOnCrash(id: string): boolean {
|
|
try {
|
|
const value = localStorage.getItem(key(id));
|
|
return value === null ? fallback() : value === "1";
|
|
} catch {
|
|
return fallback();
|
|
}
|
|
}
|
|
|
|
export function setAutoRestartOnCrash(id: string, on: boolean) {
|
|
try {
|
|
localStorage.setItem(key(id), on ? "1" : "0");
|
|
} catch {
|
|
/* storage unavailable */
|
|
}
|
|
}
|
|
|
|
export function useAutoRestart(id: string): [boolean, (on: boolean) => void] {
|
|
const [on, setOn] = useState(() => autoRestartOnCrash(id));
|
|
return [
|
|
on,
|
|
(next) => {
|
|
setAutoRestartOnCrash(id, next);
|
|
setOn(next);
|
|
},
|
|
];
|
|
}
|