mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-05-06 02:07:00 +00:00
fix(models.dev): correct init environment read and add UI error states
This commit is contained in:
parent
7c59f05681
commit
e91d19e132
2 changed files with 21 additions and 4 deletions
|
|
@ -107,11 +107,16 @@ export default function ModelsDevSyncTab() {
|
|||
});
|
||||
if (!res.ok) {
|
||||
setEnabled(!newVal);
|
||||
setFeedback({ type: "error", message: t("enableSyncError") || "Failed to update" });
|
||||
} else {
|
||||
setFeedback({ type: "success", message: "Settings saved" });
|
||||
}
|
||||
} catch {
|
||||
setEnabled(!newVal);
|
||||
setFeedback({ type: "error", message: "Network error" });
|
||||
} finally {
|
||||
setSaving(false);
|
||||
setTimeout(() => setFeedback(null), 3000);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -126,9 +131,15 @@ export default function ModelsDevSyncTab() {
|
|||
});
|
||||
if (!res.ok) {
|
||||
setIntervalHours(oldInterval);
|
||||
setFeedback({ type: "error", message: t("enableSyncError") || "Failed to update" });
|
||||
} else {
|
||||
setFeedback({ type: "success", message: "Interval updated" });
|
||||
}
|
||||
} catch {
|
||||
setIntervalHours(oldInterval);
|
||||
setFeedback({ type: "error", message: "Network error" });
|
||||
} finally {
|
||||
setTimeout(() => setFeedback(null), 3000);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -660,7 +660,8 @@ export function stopPeriodicSync(): void {
|
|||
* Get current sync status.
|
||||
*/
|
||||
export function getSyncStatus(): SyncStatus {
|
||||
const enabled = process.env.MODELS_DEV_SYNC_ENABLED === "true";
|
||||
// If the sync timer is active, it's enabled.
|
||||
const enabled = syncTimer !== null;
|
||||
return {
|
||||
enabled,
|
||||
lastSync: lastSyncTime,
|
||||
|
|
@ -680,9 +681,14 @@ export function getSyncStatus(): SyncStatus {
|
|||
* Initialize models.dev sync if enabled.
|
||||
*/
|
||||
export async function initModelsDevSync(): Promise<void> {
|
||||
if (process.env.MODELS_DEV_SYNC_ENABLED !== "true") {
|
||||
console.log("[MODELS_DEV] Disabled (set MODELS_DEV_SYNC_ENABLED=true to enable)");
|
||||
const { getSettings } = await import("./localDb");
|
||||
const settings = await getSettings();
|
||||
|
||||
if (settings.modelsDevSyncEnabled !== true) {
|
||||
console.log("[MODELS_DEV] Disabled (enable via Settings > AI)");
|
||||
return;
|
||||
}
|
||||
startPeriodicSync();
|
||||
|
||||
const interval = settings.modelsDevSyncInterval as number | undefined;
|
||||
startPeriodicSync(interval);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue