Skip to content

Commit 00ea55b

Browse files
committed
feat: integrate general settings for update checks and add disabled-state signal in /update route
1 parent 19106ed commit 00ea55b

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

apps/desktop/src/routes/(window-chrome)/new-main/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import Mode from "~/components/Mode";
3535
import { RecoveryToast } from "~/components/RecoveryToast";
3636
import Tooltip from "~/components/Tooltip";
3737
import { Input } from "~/routes/editor/ui";
38-
import { authStore } from "~/store";
38+
import { authStore, generalSettingsStore } from "~/store";
3939
import { createSignInMutation } from "~/utils/auth";
4040
import { createTauriEventListener } from "~/utils/createEventListener";
4141
import {
@@ -930,6 +930,10 @@ function createUpdateCheck() {
930930

931931
let update: updater.Update | undefined;
932932
try {
933+
const generalSettings = await generalSettingsStore.get();
934+
935+
if (generalSettings?.disableUpdateChecks ?? false) return;
936+
933937
const result = await updater.check();
934938
if (result) update = result;
935939
} catch (e) {

apps/desktop/src/routes/(window-chrome)/update.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import { generalSettingsStore } from "~/store";
99
export default function () {
1010
const navigate = useNavigate();
1111
const [updateError, setUpdateError] = createSignal<string | null>(null);
12+
const [updatesDisabled, setUpdatesDisabled] = createSignal<boolean>(false);
1213

1314
const [update] = createResource(async () => {
1415
try {
15-
const settings = await generalSettingsStore.get();
16-
const isDisabled = settings?.disableUpdateChecks ?? false;
16+
const generalSettings = await generalSettingsStore.get();
1717

18-
if(isDisabled) {
19-
setUpdateError("Update checks are currently disabled.");
18+
if (generalSettings?.disableUpdateChecks ?? false) {
19+
setUpdatesDisabled(true);
2020
return;
2121
}
2222

@@ -32,6 +32,15 @@ export default function () {
3232

3333
return (
3434
<div class="flex flex-col justify-center flex-1 items-center gap-[3rem] p-[1rem] text-[0.875rem] font-[400] h-full">
35+
<Show when={updatesDisabled()}>
36+
<div class="flex flex-col gap-4 items-center text-center max-w-md">
37+
<p class="text-[--text-primary]">Update checks are currently disabled.</p>
38+
<p class="text-[--text-tertiary]">
39+
To enable updates, go to General Settings and disable "Disable Update Checks".
40+
</p>
41+
<Button onClick={() => navigate("/")}>Go Back</Button>
42+
</div>
43+
</Show>
3544
<Show when={updateError()}>
3645
<div class="flex flex-col gap-4 items-center text-center max-w-md">
3746
<p class="text-[--text-primary]">{updateError()}</p>
@@ -48,7 +57,7 @@ export default function () {
4857
<Show
4958
when={!updateError() && update()}
5059
fallback={
51-
!updateError() && (
60+
!updateError() && !updatesDisabled() && (
5261
<span class="text-[--text-tertiary]">No update available</span>
5362
)
5463
}

0 commit comments

Comments
 (0)