This commit is contained in:
miles committed 2026-07-17 15:03:20 -05:00
1 parent 2e0ec5f70c
commit 44c2ce91a1
22 files changed
+887 -841

No files matched your search

+6 -2
View File
@@ -1,4 +1,4 @@
import React, { useEffect, useState, useCallback } from 'react';
import React, { useEffect, useState, useCallback, useRef } from 'react';
interface BiosEntry {
emulators: string[];
@@ -23,6 +23,9 @@ export function BiosCheckPanel({ biosDir, onBiosDirChange }: Props) {
const [results, setResults] = useState<BiosCheckResult[]>([]);
const [loading, setLoading] = useState(false);
const [retroarchConfigMsg, setRetroarchConfigMsg] = useState('');
const statusTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
useEffect(() => { return () => { if (statusTimer.current) clearTimeout(statusTimer.current); }; }, []);
const scan = useCallback(async (dir?: string) => {
setLoading(true);
@@ -52,7 +55,8 @@ export function BiosCheckPanel({ biosDir, onBiosDirChange }: Props) {
const configDir = homeDir + '/Library/Application Support/RetroArch';
const ok = await window.omni.bios.configureRetroArch(configDir, biosDir);
setRetroarchConfigMsg(ok ? 'RetroArch BIOS path updated' : 'Failed to update RetroArch config');
setTimeout(() => setRetroarchConfigMsg(''), 4000);
if (statusTimer.current) clearTimeout(statusTimer.current);
statusTimer.current = setTimeout(() => setRetroarchConfigMsg(''), 4000);
};
return (
+1
View File
@@ -169,6 +169,7 @@ export function useGamepadNav(onNavigate: (page: Page) => void, currentPage: Pag
raf = requestAnimationFrame(poll);
return () => {
cancelAnimationFrame(raf);
if (legendTimer.current) clearTimeout(legendTimer.current);
};
}, [onNavigate, showLegendTemporarily]);
+4 -1
View File
@@ -51,6 +51,7 @@ export function ControllerPage() {
const [emulators, setEmulators] = useState<EmulatorState[]>([]);
const [configStatus, setConfigStatus] = useState<string>('');
const rafRef = useRef<number>(0);
const statusTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const poll = useCallback(() => {
const gamepads = navigator.getGamepads();
@@ -109,6 +110,7 @@ export function ControllerPage() {
window.removeEventListener('gamepadconnected', onConnected);
window.removeEventListener('gamepaddisconnected', onDisconnected);
cancelAnimationFrame(rafRef.current);
if (statusTimerRef.current) clearTimeout(statusTimerRef.current);
};
}, [poll]);
@@ -120,7 +122,8 @@ export function ControllerPage() {
} catch (e: any) {
setConfigStatus(`Error: ${e.message}`);
}
setTimeout(() => setConfigStatus(''), 4000);
if (statusTimerRef.current) clearTimeout(statusTimerRef.current);
statusTimerRef.current = setTimeout(() => setConfigStatus(''), 4000);
};
return (
+19 -12
View File
@@ -8,18 +8,23 @@ export function Dashboard({ onNavigate }: { onNavigate?: (tab: 'dashboard' | 'em
const [loading, setLoading] = useState(true);
useEffect(() => {
let cancelled = false;
async function load() {
const [states, info, recentGames] = await Promise.all([
window.omni.emulators.states(),
window.omni.system.info(),
window.omni.game.recent(),
]);
setEmulators(states);
setSystem(info);
setRecent(recentGames || []);
setLoading(false);
try {
const [states, info, recentGames] = await Promise.all([
window.omni.emulators.states(),
window.omni.system.info(),
window.omni.game.recent(),
]);
if (cancelled) return;
setEmulators(states);
setSystem(info);
setRecent(recentGames || []);
} catch { /* ignore */ }
if (!cancelled) setLoading(false);
}
load();
return () => { cancelled = true; };
}, []);
const installed = emulators.filter((e) => e.installed).length;
@@ -103,9 +108,11 @@ export function Dashboard({ onNavigate }: { onNavigate?: (tab: 'dashboard' | 'em
tabIndex={0}
role="button"
onClick={async () => {
await window.omni.game.launch(game.emulatorId, game.romPath);
const updated = await window.omni.game.recent();
setRecent(updated || []);
try {
await window.omni.game.launch(game.emulatorId, game.romPath);
const updated = await window.omni.game.recent();
setRecent(updated || []);
} catch { /* ignore */ }
}}
>
<div className="game-card-cover">
+69 -48
View File
@@ -15,6 +15,7 @@ export function EmulatorsPage() {
const [states, setStates] = useState<EmulatorState[]>([]);
const [decompStates, setDecompStates] = useState<DecompState[]>([]);
const [betaFeatures, setBetaFeatures] = useState(false);
const [frontendSupport, setFrontendSupport] = useState(false);
const [decompProjects, setDecompProjects] = useState(false);
const [loading, setLoading] = useState(true);
const [progress, setProgress] = useState<Record<string, InstallProgress>>({});
@@ -25,15 +26,18 @@ export function EmulatorsPage() {
const load = useCallback(async () => {
setLoading(true);
const [emuResult, decompResult, settings] = await Promise.all([
window.omni.emulators.states(),
window.omni.decomps.states(),
window.omni.settings.get(),
]);
setStates(emuResult);
setDecompStates(decompResult);
setBetaFeatures(!!settings.betaFeatures);
setDecompProjects(!!settings.decompProjects);
try {
const [emuResult, decompResult, settings] = await Promise.all([
window.omni.emulators.states(),
window.omni.decomps.states(),
window.omni.settings.get(),
]);
setStates(emuResult);
setDecompStates(decompResult);
setBetaFeatures(!!settings.betaFeatures);
setFrontendSupport(!!settings.frontendSupport);
setDecompProjects(!!settings.decompProjects);
} catch { /* ignore */ }
setLoading(false);
}, []);
@@ -73,7 +77,8 @@ export function EmulatorsPage() {
...prev,
[id]: { emulatorId: id, stage: 'downloading', percent: 0, message: 'Starting...' },
}));
await window.omni.emulators.install(id);
try { await window.omni.emulators.install(id); } catch { /* ignore */ }
setActioning(null);
await load();
};
@@ -83,10 +88,13 @@ export function EmulatorsPage() {
...prev,
[id]: { emulatorId: id, stage: 'downloading', percent: 0, message: 'Starting...' },
}));
const result = await window.omni.emulators.install(id);
if (result.installed && result.path) {
await window.omni.emulators.configure(id, result.path);
}
try {
const result = await window.omni.emulators.install(id);
if (result.installed && result.path) {
await window.omni.emulators.configure(id, result.path);
}
} catch { /* ignore */ }
setActioning(null);
await load();
};
@@ -100,7 +108,7 @@ export function EmulatorsPage() {
stage: 'configuring', percent: 0, message: 'Applying recommended settings...',
},
}));
await window.omni.emulators.configure(state.config.id, state.path);
try { await window.omni.emulators.configure(state.config.id, state.path); } catch { /* ignore */ }
setProgress((prev) => ({
...prev,
[state.config.id]: {
@@ -115,20 +123,20 @@ export function EmulatorsPage() {
const handleOpen = async (id: string) => {
setActioning(id);
await window.omni.emulators.launch(id);
try { await window.omni.emulators.launch(id); } catch { /* ignore */ }
setActioning(null);
};
const handleUninstall = async (id: string) => {
if (!confirm(`Uninstall ${id} and remove all its files?`)) return;
setActioning(id);
await window.omni.emulators.uninstall(id);
try { await window.omni.emulators.uninstall(id); } catch { /* ignore */ }
setActioning(null);
await load();
};
const handleOpenWebsite = async (id: string) => {
await window.omni.emulators.openWebsite(id);
try { await window.omni.emulators.openWebsite(id); } catch { /* ignore */ }
};
// ── Decomp handlers ───────────────────────────────────────
@@ -139,31 +147,33 @@ export function EmulatorsPage() {
...prev,
[id]: { stage: 'downloading', percent: 0, message: 'Starting...' },
}));
await window.omni.decomps.install(id);
try { await window.omni.decomps.install(id); } catch { /* ignore */ }
await load();
};
const handleDecompUninstall = async (id: string) => {
if (!confirm(`Uninstall this port and remove all its files?`)) return;
setActioning(id);
await window.omni.decomps.uninstall(id);
try { await window.omni.decomps.uninstall(id); } catch { /* ignore */ }
setActioning(null);
await load();
};
const handleDecompLaunch = async (id: string) => {
setActioning(id);
await window.omni.decomps.launch(id);
try { await window.omni.decomps.launch(id); } catch { /* ignore */ }
setActioning(null);
};
const handleDecompSelectRom = async (id: string) => {
const result = await window.omni.decomps.selectRom(id);
if (result.state) {
setDecompStates((prev) =>
prev.map((d) => (d.config.id === id ? result.state : d))
);
}
try {
const result = await window.omni.decomps.selectRom(id);
if (result.state) {
setDecompStates((prev) =>
prev.map((d) => (d.config.id === id ? result.state : d))
);
}
} catch { /* ignore */ }
};
const handleRefresh = () => load();
@@ -174,16 +184,23 @@ export function EmulatorsPage() {
const currentProgress = (id: string) => progress[id];
const emulators = states.filter((s) => s.config.id !== 'emubuddy' && !FRONTEND_IDS.has(s.config.id));
const frontends = states.filter((s) => FRONTEND_IDS.has(s.config.id) || s.config.id === 'emubuddy');
const installedCount = states.filter((s) => s.installed).length;
const configuredCount = states.filter((s) => s.configured).length;
const allEmulators = states.filter((s) => s.config.id !== 'emubuddy' && !FRONTEND_IDS.has(s.config.id));
const allFrontends = states.filter((s) => FRONTEND_IDS.has(s.config.id) || s.config.id === 'emubuddy');
const emulators = betaFeatures ? allEmulators : allEmulators.filter((s) => !s.config.beta);
const frontends = frontendSupport ? allFrontends : [];
const visibleStates = [...emulators, ...frontends];
const installedCount = visibleStates.filter((s) => s.installed).length;
const configuredCount = visibleStates.filter((s) => s.configured).length;
const filteredStates = activeTab === 'emulators'
? emulators
: activeTab === 'frontends'
? frontends
: states;
: activeTab === 'decomps'
? []
: visibleStates;
const showDecomps = decompProjects && (activeTab === 'all' || activeTab === 'decomps');
@@ -208,7 +225,7 @@ export function EmulatorsPage() {
onClick={() => setActiveTab('all')}
>
All
<span className="page-tab-count">{states.length + (showDecomps ? decompStates.length : 0)}</span>
<span className="page-tab-count">{visibleStates.length + (showDecomps ? decompStates.length : 0)}</span>
</button>
<button
className={`page-tab ${activeTab === 'emulators' ? 'active' : ''}`}
@@ -217,13 +234,15 @@ export function EmulatorsPage() {
Emulators
<span className="page-tab-count">{emulators.length}</span>
</button>
<button
className={`page-tab ${activeTab === 'frontends' ? 'active' : ''}`}
onClick={() => setActiveTab('frontends')}
>
Frontends
<span className="page-tab-count">{frontends.length}</span>
</button>
{frontendSupport && (
<button
className={`page-tab ${activeTab === 'frontends' ? 'active' : ''}`}
onClick={() => setActiveTab('frontends')}
>
Frontends
<span className="page-tab-count">{frontends.length}</span>
</button>
)}
{decompProjects && (
<button
className={`page-tab ${activeTab === 'decomps' ? 'active' : ''}`}
@@ -244,7 +263,7 @@ export function EmulatorsPage() {
return (
<div className="card" key={state.config.id}>
<div className="card-header">
<h3>{state.config.name}</h3>
<h3>{state.config.name} {state.config.beta && <span className="badge-beta" style={{ marginLeft: 6, fontSize: 10, verticalAlign: 'middle' }}>Beta</span>}</h3>
<span
className={`badge ${
!state.config.supported
@@ -407,13 +426,15 @@ export function EmulatorsPage() {
{/* ── Decompilations Section ───────────────────────── */}
{showDecomps && (<>
<div style={{ marginTop: 40 }}>
<div className="info-bar" style={{ marginBottom: 16 }}>
<h2 style={{ fontSize: 20, fontWeight: 600 }}>Decompilations <span className="badge-beta">Beta</span></h2>
<span className="text-sm text-muted">
Native PC ports built from reverse-engineered source code — bring your own ROM
</span>
</div>
<div style={{ marginTop: activeTab === 'decomps' ? 0 : 40 }}>
{activeTab !== 'decomps' && (
<div className="info-bar" style={{ marginBottom: 16 }}>
<h2 style={{ fontSize: 20, fontWeight: 600 }}>Decompilations <span className="badge-beta">Beta</span></h2>
<span className="text-sm text-muted">
Native PC ports built from reverse-engineered source code — bring your own ROM
</span>
</div>
)}
<div className="card-grid">
{decompStates.map((decomp) => {
+28 -18
View File
@@ -19,20 +19,28 @@ export function LibraryPage() {
const [selectedGame, setSelectedGame] = useState<GameEntry | null>(null);
useEffect(() => {
let cancelled = false;
(async () => {
const settings = await window.omni.settings.get();
setDecompProjects(!!settings.decompProjects);
if (settings.romsDirectory) {
setRomsDir(settings.romsDirectory);
setLoading(true);
const results = await window.omni.roms.scan(settings.romsDirectory);
setGames(await scrapeMissingArt(results));
setLoading(false);
}
// Load installed decomps
const decompStates = await window.omni.decomps.states();
setDecompGames(decompStates.filter(d => d.installed));
try {
const settings = await window.omni.settings.get();
if (cancelled) return;
setDecompProjects(!!settings.decompProjects);
if (settings.romsDirectory) {
setRomsDir(settings.romsDirectory);
setLoading(true);
const results = await window.omni.roms.scan(settings.romsDirectory);
if (cancelled) return;
setGames(await scrapeMissingArt(results));
setLoading(false);
}
// Load installed decomps
const decompStates = await window.omni.decomps.states();
if (cancelled) return;
setDecompGames(decompStates.filter(d => d.installed));
} catch { /* ignore */ }
if (!cancelled) setLoading(false);
})();
return () => { cancelled = true; };
}, []);
const scrapeMissingArt = async (list: GameEntry[]): Promise<GameEntry[]> => {
@@ -52,9 +60,11 @@ export function LibraryPage() {
const scanDirectory = useCallback(async (dir: string) => {
setRomsDir(dir);
setLoading(true);
await window.omni.settings.save({ romsDirectory: dir });
const results = await window.omni.roms.scan(dir);
setGames(await scrapeMissingArt(results));
try {
await window.omni.settings.save({ romsDirectory: dir });
const results = await window.omni.roms.scan(dir);
setGames(await scrapeMissingArt(results));
} catch { /* ignore */ }
setLoading(false);
}, []);
@@ -65,12 +75,12 @@ export function LibraryPage() {
}, [scanDirectory]);
const handleLaunch = async (game: GameEntry) => {
await window.omni.game.launch(game.emulatorId, game.romPath);
try { await window.omni.game.launch(game.emulatorId, game.romPath); } catch { /* ignore */ }
};
const handleDecompLaunch = async (decomp: DecompState) => {
if (decomp.romPath) {
await window.omni.decomps.launch(decomp.config.id);
try { await window.omni.decomps.launch(decomp.config.id); } catch { /* ignore */ }
}
};
@@ -123,7 +133,7 @@ export function LibraryPage() {
<div style={{ display: 'flex', gap: 6 }}>
<button className="btn btn-secondary btn-sm" onClick={async () => {
setLoading(true);
setGames(await scrapeMissingArt(games));
try { setGames(await scrapeMissingArt(games)); } catch { /* ignore */ }
setLoading(false);
}}>
Scrape All Art
+116 -19
View File
@@ -1,5 +1,5 @@
import React, { useEffect, useState, useCallback } from 'react';
import type { GameEntry, EmulatorSaves, SaveEntry, SyncthingFolder } from '../../shared/types';
import React, { useEffect, useState, useCallback, useRef } from 'react';
import type { GameEntry, EmulatorSaves, SaveEntry, SyncthingFolder, BackupEntry } from '../../shared/types';
function formatSize(bytes: number): string {
if (bytes < 1024) return `${bytes} B`;
@@ -47,30 +47,41 @@ export function SaveManagerPage() {
const [loading, setLoading] = useState(true);
const [expandedGame, setExpandedGame] = useState<string | null>(null);
const [status, setStatus] = useState('');
const [view, setView] = useState<'games' | 'emulators'>('games');
const [view, setView] = useState<'games' | 'emulators' | 'backups'>('games');
const [syncFolders, setSyncFolders] = useState<SyncthingFolder[]>([]);
const [cloudEnabled, setCloudEnabled] = useState(false);
const [togglingSync, setTogglingSync] = useState<string | null>(null);
const [backups, setBackups] = useState<BackupEntry[]>([]);
const [restoring, setRestoring] = useState<string | null>(null);
const statusTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
useEffect(() => { return () => { if (statusTimer.current) clearTimeout(statusTimer.current); }; }, []);
const loadData = useCallback(async () => {
setLoading(true);
const [settings, saves] = await Promise.all([
window.omni.settings.get(),
window.omni.saves.list(),
]);
setAllSaves(saves);
if (settings.romsDirectory) {
const roms = await window.omni.roms.scan(settings.romsDirectory);
setGames(roms);
}
// Detect cloud sync: either the flag is set, or Syncthing is actually running
let cloudOk = !!settings.cloudSyncEnabled;
try {
const cloudStatus = await window.omni.cloud.status();
setSyncFolders(cloudStatus.folders || []);
if (cloudStatus.running) cloudOk = true;
const [settings, saves] = await Promise.all([
window.omni.settings.get(),
window.omni.saves.list(),
]);
setAllSaves(saves);
if (settings.romsDirectory) {
const roms = await window.omni.roms.scan(settings.romsDirectory);
setGames(roms);
}
// Detect cloud sync: either the flag is set, or Syncthing is actually running
let cloudOk = !!settings.cloudSyncEnabled;
try {
const cloudStatus = await window.omni.cloud.status();
setSyncFolders(cloudStatus.folders || []);
if (cloudStatus.running) cloudOk = true;
} catch { /* ignore */ }
setCloudEnabled(cloudOk);
try {
const backupList = await window.omni.saves.listBackups();
setBackups(backupList);
} catch { /* ignore */ }
} catch { /* ignore */ }
setCloudEnabled(cloudOk);
setLoading(false);
}, []);
@@ -78,7 +89,8 @@ export function SaveManagerPage() {
const showStatus = (msg: string) => {
setStatus(msg);
setTimeout(() => setStatus(''), 3000);
if (statusTimer.current) clearTimeout(statusTimer.current);
statusTimer.current = setTimeout(() => setStatus(''), 3000);
};
const allSaveFiles = allSaves.flatMap(e => e.saves);
@@ -149,6 +161,27 @@ export function SaveManagerPage() {
setTogglingSync(null);
};
const handleRestore = async (backup: BackupEntry) => {
if (!confirm(`Restore ${backup.originalName}? This will overwrite the current save file.`)) return;
setRestoring(backup.backupPath);
try {
const ok = await window.omni.saves.restore(backup.backupPath);
if (ok) {
showStatus(`Restored ${backup.originalName}`);
loadData();
} else {
showStatus('Restore failed — could not find original save location');
}
} catch {
showStatus('Restore failed');
}
setRestoring(null);
};
const handleOpenBackupFolder = async () => {
try { await window.omni.saves.openBackupFolder(); } catch { /* ignore */ }
};
return (
<div>
<div className="info-bar mb-4" style={{ justifyContent: 'space-between' }}>
@@ -166,6 +199,12 @@ export function SaveManagerPage() {
>
By Emulator
</button>
<button
className={`btn btn-sm ${view === 'backups' ? 'btn-primary' : 'btn-secondary'}`}
onClick={() => setView('backups')}
>
Backups {backups.length > 0 && <span style={{ opacity: 0.7 }}>({backups.length})</span>}
</button>
<button className="btn btn-secondary btn-sm" onClick={loadData}>
Refresh
</button>
@@ -311,6 +350,64 @@ export function SaveManagerPage() {
</div>
))
)}
{!loading && view === 'backups' && (
<div>
<div className="info-bar mb-4" style={{ justifyContent: 'space-between' }}>
<span>{backups.length} backup{backups.length !== 1 ? 's' : ''}</span>
<button className="btn btn-secondary btn-sm" onClick={handleOpenBackupFolder}>
Open Backup Folder
</button>
</div>
{backups.length === 0 ? (
<div className="empty-state">
<div className="empty-state-icon">📁</div>
<h3>No backups yet</h3>
<p>Click "Backup" next to any save file to create a backup.</p>
</div>
) : (
<div className="card">
<div style={{ padding: 12 }}>
{backups.map((backup) => (
<div
key={backup.backupPath}
style={{
display: 'flex',
alignItems: 'center',
gap: 10,
padding: '8px 10px',
borderRadius: 8,
border: '1px solid var(--border)',
marginBottom: 4,
background: 'var(--bg-tertiary)',
}}
>
<span style={{ fontSize: 16, flexShrink: 0 }}>📦</span>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 13, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{backup.originalName}
</div>
<div className="text-sm text-muted" style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{formatDate(backup.backupTime)} · {formatSize(backup.fileSize)}
</div>
</div>
<div style={{ display: 'flex', gap: 4, flexShrink: 0 }}>
<button
className="btn btn-primary btn-sm"
disabled={restoring === backup.backupPath}
onClick={() => handleRestore(backup)}
>
{restoring === backup.backupPath ? 'Restoring...' : 'Restore'}
</button>
</div>
</div>
))}
</div>
</div>
)}
</div>
)}
</div>
);
}
+12 -7
View File
@@ -67,41 +67,46 @@ export function SettingsPage() {
}, []);
useEffect(() => {
let cancelled = false;
Promise.all([
window.omni.settings.get(),
window.omni.emulators.systemAssignments(),
window.omni.emulators.list(),
]).then(([s, assignments, emulators]) => {
if (cancelled) return;
setSettings(s);
setSystemAssignments(assignments);
const nameMap: Record<string, string> = {};
for (const e of emulators) nameMap[e.id] = e.name;
setEmuNameMap(nameMap);
});
}).catch(() => { if (!cancelled) setSettings({} as AppSettings); });
return () => { cancelled = true; };
}, []);
const update = async (partial: Partial<AppSettings>) => {
if (!settings) return;
setSaving(true);
const updated = await window.omni.settings.save(partial);
setSettings(updated);
try {
const updated = await window.omni.settings.save(partial);
setSettings(updated);
} catch { /* ignore */ }
setSaving(false);
};
const handleCheckUpdates = async () => {
setChecking(true);
setUpdateInfo(null);
await window.omni.updates.check();
try { await window.omni.updates.check(); } catch { setChecking(false); }
};
const handleDownloadUpdate = async () => {
setDownloading(true);
setDownloadProgress(0);
await window.omni.updates.download();
try { await window.omni.updates.download(); } catch { setDownloading(false); }
};
const handleQuitAndInstall = async () => {
await window.omni.updates.quitAndInstall();
try { await window.omni.updates.quitAndInstall(); } catch { /* app is restarting */ }
};
if (!settings || !systemAssignments) {
@@ -407,7 +412,7 @@ export function SettingsPage() {
onClick={async () => {
if (!confirm('This will delete all emulators, settings, and app data. Your ROMs are safe. Continue?')) return;
if (!confirm('Are you really sure? This cannot be undone.')) return;
await window.omni.app.nukeData();
try { await window.omni.app.nukeData(); } catch { /* ignore */ }
window.location.reload();
}}
>
+27 -8
View File
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useRef } from 'react';
interface FilterPreset {
id: string;
@@ -24,6 +24,25 @@ export function UtilitiesPage() {
const [filterResult, setFilterResult] = useState<{ message: string; ok: boolean } | null>(null);
const [applyingAll, setApplyingAll] = useState(false);
const [applyAllResult, setApplyAllResult] = useState<string | null>(null);
const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);
const clearTimer = (ref: ReturnType<typeof setTimeout>) => {
clearTimeout(ref);
const idx = timerRefs.current.indexOf(ref);
if (idx >= 0) timerRefs.current.splice(idx, 1);
};
const addTimer = (ms: number, cb: () => void): ReturnType<typeof setTimeout> => {
const t = setTimeout(() => {
const idx = timerRefs.current.indexOf(t);
if (idx >= 0) timerRefs.current.splice(idx, 1);
cb();
}, ms);
timerRefs.current.push(t);
return t;
};
useEffect(() => { return () => { timerRefs.current.forEach(clearTimeout); }; }, []);
useEffect(() => {
window.omni.settings.get().then((s) => {
@@ -31,14 +50,14 @@ export function UtilitiesPage() {
setRaPassword(s.retroAchievementsPassword || '');
setRaApiKey(s.retroAchievementsApiKey || '');
setSgdbKey(s.steamGridDbApiKey || '');
});
window.omni.filters.list().then(setFilterPresets);
}).catch(() => { /* ignore */ });
window.omni.filters.list().then(setFilterPresets).catch(() => { /* ignore */ });
}, []);
const handleRecreate = async () => {
setRegenerating(true);
await window.omni.utilities.regenerateRomsStructure();
setTimeout(() => setRegenerating(false), 1500);
addTimer(1500, () => setRegenerating(false));
};
const handleAutoApply = async () => {
@@ -68,7 +87,7 @@ export function UtilitiesPage() {
} catch {
setFilterResult({ message: 'Failed to apply filter', ok: false });
}
setTimeout(() => { setApplyingFilter(null); setFilterResult(null); }, 2500);
addTimer(2500, () => { setApplyingFilter(null); setFilterResult(null); });
};
const handleApplyAll = async () => {
@@ -82,7 +101,7 @@ export function UtilitiesPage() {
} catch {
setApplyAllResult('Failed to apply settings');
}
setTimeout(() => { setApplyingAll(false); setApplyAllResult(null); }, 3000);
addTimer(3000, () => { setApplyingAll(false); setApplyAllResult(null); });
};
const handleRaSave = async () => {
@@ -99,7 +118,7 @@ export function UtilitiesPage() {
} catch {
setRaResults({});
}
setTimeout(() => setSaving(false), 500);
addTimer(500, () => setSaving(false));
};
const emuLabels: Record<string, string> = {
@@ -376,7 +395,7 @@ export function UtilitiesPage() {
if (!window.confirm('Are you sure you want to clear all game covers? This cannot be undone.')) return;
setClearingCovers(true);
await window.omni.game.clearCoverCache();
setTimeout(() => setClearingCovers(false), 1500);
addTimer(1500, () => setClearingCovers(false));
}}
>
{clearingCovers ? 'Cleared!' : 'Clear Covers'}
+384 -677
View File
File diff suppressed because it is too large. Load diff
+5
View File
@@ -11,6 +11,7 @@ import type {
InstallProgress,
ConfigPreset,
EmulatorSaves,
BackupEntry,
SyncthingStatus,
SyncthingPendingDevice,
SyncthingPendingFolder,
@@ -89,6 +90,9 @@ declare global {
list: () => Promise<EmulatorSaves[]>;
delete: (filePath: string) => Promise<boolean>;
backup: (filePath: string) => Promise<string | null>;
listBackups: () => Promise<BackupEntry[]>;
restore: (backupPath: string) => Promise<boolean>;
openBackupFolder: () => Promise<boolean>;
openFolder: (folderPath: string) => Promise<boolean>;
selectDirectory: () => Promise<string | null>;
setDirectory: (emulatorId: string, dir: string) => Promise<boolean>;
@@ -124,6 +128,7 @@ declare global {
guessPath: (label: string) => Promise<string | null>;
emulatorDirs: () => Promise<{ id: string; name: string; saves: string | null }[]>;
toggleFolderSync: (emuId: string, sync: boolean) => Promise<boolean>;
uninstall: () => Promise<boolean>;
onInstallProgress: (cb: (progress: { stage: string; percent: number; message: string }) => void) => () => void;
};
app: {