mirror of
https://github.com/different-ai/openwork
synced 2026-04-25 17:15:34 +02:00
fix(app): check for updates every 12h and show update available
This commit is contained in:
@@ -2242,6 +2242,21 @@ export default function App() {
|
||||
anyActiveRuns,
|
||||
} = systemState;
|
||||
|
||||
const UPDATE_AUTO_CHECK_EVERY_MS = 12 * 60 * 60_000;
|
||||
const UPDATE_AUTO_CHECK_POLL_MS = 60_000;
|
||||
|
||||
const getUpdateLastCheckedAt = (state: ReturnType<typeof updateStatus>) => {
|
||||
if (state.state === "checking") return null;
|
||||
return state.lastCheckedAt ?? null;
|
||||
};
|
||||
|
||||
const shouldAutoCheckForUpdates = () => {
|
||||
const state = updateStatus();
|
||||
const lastCheckedAt = getUpdateLastCheckedAt(state);
|
||||
if (!lastCheckedAt) return true;
|
||||
return Date.now() - lastCheckedAt >= UPDATE_AUTO_CHECK_EVERY_MS;
|
||||
};
|
||||
|
||||
const [pendingReloadReasons, setPendingReloadReasons] = createSignal<ReloadReason[]>([]);
|
||||
const [pendingReloadTrigger, setPendingReloadTrigger] = createSignal<ReloadTrigger | null>(null);
|
||||
const [pendingReloadResume, setPendingReloadResume] = createSignal<
|
||||
@@ -3880,15 +3895,6 @@ export default function App() {
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
if (updateAutoCheck()) {
|
||||
const state = updateStatus();
|
||||
const lastCheckedAt =
|
||||
state.state === "idle" ? state.lastCheckedAt : null;
|
||||
if (!lastCheckedAt || Date.now() - lastCheckedAt > 24 * 60 * 60_000) {
|
||||
checkForUpdates({ quiet: true }).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void workspaceStore.bootstrapOnboarding().finally(() => setBooting(false));
|
||||
@@ -4221,6 +4227,26 @@ export default function App() {
|
||||
}
|
||||
});
|
||||
|
||||
createEffect(() => {
|
||||
if (booting()) return;
|
||||
if (typeof window === "undefined") return;
|
||||
if (!isTauriRuntime()) return;
|
||||
if (!updateAutoCheck()) return;
|
||||
|
||||
const maybeRunAutoUpdateCheck = () => {
|
||||
if (!updateAutoCheck()) return;
|
||||
const state = updateStatus();
|
||||
if (state.state === "checking" || state.state === "downloading") return;
|
||||
if (!shouldAutoCheckForUpdates()) return;
|
||||
checkForUpdates({ quiet: true }).catch(() => undefined);
|
||||
};
|
||||
|
||||
maybeRunAutoUpdateCheck();
|
||||
|
||||
const interval = window.setInterval(maybeRunAutoUpdateCheck, UPDATE_AUTO_CHECK_POLL_MS);
|
||||
onCleanup(() => window.clearInterval(interval));
|
||||
});
|
||||
|
||||
createEffect(() => {
|
||||
if (!isTauriRuntime()) return;
|
||||
if (!updateAutoDownload()) return;
|
||||
|
||||
@@ -686,7 +686,7 @@ export default function DashboardView(props: DashboardViewProps) {
|
||||
return props.anyActiveRuns ? "Update ready" : "Restart";
|
||||
}
|
||||
if (state === "downloading") return "Downloading";
|
||||
return "Update";
|
||||
return "Update available";
|
||||
});
|
||||
|
||||
const updatePillTitle = createMemo(() => {
|
||||
|
||||
@@ -1347,7 +1347,7 @@ export default function SessionView(props: SessionViewProps) {
|
||||
return props.anyActiveRuns ? "Update ready" : "Restart";
|
||||
}
|
||||
if (state === "downloading") return "Downloading";
|
||||
return "Update";
|
||||
return "Update available";
|
||||
});
|
||||
|
||||
const updatePillTitle = createMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user