Skip to content

Commit 286fa50

Browse files
authored
Merge pull request #101 from SWangHash/wc/bugfix
feat(settings): remove launch-at-login setting
2 parents e879db6 + 115e3fb commit 286fa50

6 files changed

Lines changed: 0 additions & 170 deletions

File tree

‎src/web-ui/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"@monaco-editor/react": "^4.6.0",
2222
"@tanstack/react-virtual": "^3.13.23",
2323
"@tauri-apps/api": "^2.10.1",
24-
"@tauri-apps/plugin-autostart": "^2.0.0",
2524
"@tauri-apps/plugin-dialog": "^2.6.0",
2625
"@tauri-apps/plugin-fs": "^2.0.0",
2726
"@tauri-apps/plugin-log": "^2.8.0",

‎src/web-ui/src/infrastructure/api/service-api/SystemAPI.ts‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { api } from './ApiClient';
44
import { createTauriCommandError } from '../errors/TauriCommandError';
55
import { openUrl } from '@tauri-apps/plugin-opener';
6-
import { disable as autostartDisable, enable as autostartEnable, isEnabled as autostartIsEnabled } from '@tauri-apps/plugin-autostart';
76
import { createLogger } from '@/shared/utils/logger';
87

98

@@ -172,19 +171,6 @@ export class SystemAPI {
172171
}
173172
}
174173

175-
/** Desktop only: whether the app is registered to launch at OS login. */
176-
async getLaunchAtLoginEnabled(): Promise<boolean> {
177-
if (typeof window === 'undefined' || !('__TAURI__' in window)) {
178-
return false;
179-
}
180-
try {
181-
return await autostartIsEnabled();
182-
} catch (error) {
183-
log.error('Failed to read launch-at-login state', error);
184-
throw createTauriCommandError('autostart_is_enabled', error);
185-
}
186-
}
187-
188174
/** Desktop only: send an OS-level desktop notification. */
189175
async sendSystemNotification(title: string, body?: string): Promise<void> {
190176
if (typeof window === 'undefined' || !('__TAURI__' in window)) {
@@ -199,23 +185,6 @@ export class SystemAPI {
199185
}
200186
}
201187

202-
/** Desktop only: register or unregister launch at OS login. */
203-
async setLaunchAtLoginEnabled(enabled: boolean): Promise<void> {
204-
if (typeof window === 'undefined' || !('__TAURI__' in window)) {
205-
return;
206-
}
207-
try {
208-
if (enabled) {
209-
await autostartEnable();
210-
} else {
211-
await autostartDisable();
212-
}
213-
} catch (error) {
214-
log.error('Failed to set launch-at-login', { enabled, error });
215-
throw createTauriCommandError('autostart_set', error, { enabled });
216-
}
217-
}
218-
219188
// ─── Window / Tray behavior ────────────────────────────────────────────────
220189

221190
/** Desktop only: immediately quit the application. */

‎src/web-ui/src/infrastructure/config/components/BasicsConfig.tsx‎

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
ConfigPageMessage,
1212
} from '@/component-library';
1313
import { configAPI, workspaceAPI } from '@/infrastructure/api';
14-
import { systemAPI } from '@/infrastructure/api/service-api/SystemAPI';
1514
import type { CloseBehavior } from '@/infrastructure/api/service-api/SystemAPI';
1615
import {
1716
getTerminalService,
@@ -38,103 +37,6 @@ import './BasicsConfig.scss';
3837

3938
const log = createLogger('BasicsConfig');
4039

41-
function BasicsLaunchAtLoginSection() {
42-
const { t } = useTranslation('settings/basics');
43-
const isTauri = typeof window !== 'undefined' && '__TAURI__' in window;
44-
const [enabled, setEnabled] = useState(false);
45-
const [loading, setLoading] = useState(true);
46-
const [saving, setSaving] = useState(false);
47-
const [message, setMessage] = useState<{ type: 'success' | 'error' | 'info'; text: string } | null>(null);
48-
49-
const showMessage = useCallback((type: 'success' | 'error' | 'info', text: string) => {
50-
setMessage({ type, text });
51-
setTimeout(() => setMessage(null), 3000);
52-
}, []);
53-
54-
useEffect(() => {
55-
if (!isTauri) {
56-
setLoading(false);
57-
return;
58-
}
59-
60-
let cancelled = false;
61-
void (async () => {
62-
try {
63-
setLoading(true);
64-
const v = await systemAPI.getLaunchAtLoginEnabled();
65-
if (!cancelled) {
66-
setEnabled(v);
67-
}
68-
} catch (error) {
69-
log.error('Failed to load launch-at-login state', error);
70-
if (!cancelled) {
71-
showMessage('error', t('launchAtLogin.messages.loadFailed'));
72-
}
73-
} finally {
74-
if (!cancelled) {
75-
setLoading(false);
76-
}
77-
}
78-
})();
79-
80-
return () => {
81-
cancelled = true;
82-
};
83-
}, [isTauri, showMessage, t]);
84-
85-
const handleToggle = useCallback(
86-
async (next: boolean) => {
87-
const previous = enabled;
88-
setEnabled(next);
89-
setSaving(true);
90-
try {
91-
await systemAPI.setLaunchAtLoginEnabled(next);
92-
} catch (error) {
93-
setEnabled(previous);
94-
log.error('Failed to set launch-at-login', { next, error });
95-
showMessage('error', t('launchAtLogin.messages.saveFailed'));
96-
} finally {
97-
setSaving(false);
98-
}
99-
},
100-
[enabled, showMessage, t]
101-
);
102-
103-
if (!isTauri) {
104-
return null;
105-
}
106-
107-
if (loading) {
108-
return <ConfigPageLoading text={t('launchAtLogin.messages.loading')} />;
109-
}
110-
111-
return (
112-
<div className="bitfun-launch-at-login-config">
113-
<div className="bitfun-launch-at-login-config__content">
114-
<ConfigPageMessage message={message} />
115-
<ConfigPageSection
116-
title={t('launchAtLogin.sections.title')}
117-
description={t('launchAtLogin.sections.hint')}
118-
>
119-
<ConfigPageRow
120-
label={t('launchAtLogin.toggleLabel')}
121-
description={t('launchAtLogin.toggleDescription')}
122-
align="center"
123-
>
124-
<Switch
125-
checked={enabled}
126-
onChange={(e) => {
127-
void handleToggle(e.target.checked);
128-
}}
129-
disabled={saving}
130-
/>
131-
</ConfigPageRow>
132-
</ConfigPageSection>
133-
</div>
134-
</div>
135-
);
136-
}
137-
13840
function BasicsAutoUpdateSection() {
13941
const { t } = useTranslation('settings/basics');
14042
const isTauri = typeof window !== 'undefined' && '__TAURI__' in window;
@@ -813,7 +715,6 @@ const BasicsConfig: React.FC = () => {
813715
<ConfigPageLayout className="bitfun-basics-config">
814716
<ConfigPageHeader title={t('title')} subtitle={t('subtitle')} />
815717
<ConfigPageContent className="bitfun-basics-config__content">
816-
<BasicsLaunchAtLoginSection />
817718
<BasicsAutoUpdateSection />
818719
<BasicsWindowBehaviorSection />
819720
<BasicsLoggingSection />

‎src/web-ui/src/locales/en-US/settings/basics.json‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,6 @@
8787
"saved": "Update preference saved"
8888
}
8989
},
90-
"launchAtLogin": {
91-
"sections": {
92-
"title": "Login",
93-
"hint": "Start BitFun when you sign in to this account"
94-
},
95-
"toggleLabel": "Launch at login",
96-
"toggleDescription": "Automatically start BitFun after you log in. Exact behavior depends on your operating system.",
97-
"messages": {
98-
"loading": "Loading...",
99-
"loadFailed": "Failed to read launch-at-login setting",
100-
"saveFailed": "Failed to update launch-at-login setting"
101-
}
102-
},
10390
"logging": {
10491
"sections": {
10592
"logging": "Logging",

‎src/web-ui/src/locales/zh-CN/settings/basics.json‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,6 @@
8787
"saved": "已保存更新偏好"
8888
}
8989
},
90-
"launchAtLogin": {
91-
"sections": {
92-
"title": "登录时启动",
93-
"hint": "登录本用户后是否自动运行 BitFun"
94-
},
95-
"toggleLabel": "开机自动启动",
96-
"toggleDescription": "登录系统后自动启动 BitFun;具体表现因操作系统而异。",
97-
"messages": {
98-
"loading": "加载中…",
99-
"loadFailed": "无法读取开机启动设置",
100-
"saveFailed": "无法更新开机启动设置"
101-
}
102-
},
10390
"logging": {
10491
"sections": {
10592
"logging": "日志",

‎src/web-ui/src/locales/zh-TW/settings/basics.json‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,6 @@
7373
"flowChatPxOption": "{{n}} px"
7474
}
7575
},
76-
"launchAtLogin": {
77-
"sections": {
78-
"title": "登錄時啟動",
79-
"hint": "登錄本用戶後是否自動運行 BitFun"
80-
},
81-
"toggleLabel": "開機自動啟動",
82-
"toggleDescription": "登錄系統後自動啟動 BitFun;具體表現因操作系統而異。",
83-
"messages": {
84-
"loading": "載入中…",
85-
"loadFailed": "無法讀取開機啟動設置",
86-
"saveFailed": "無法更新開機啟動設置"
87-
}
88-
},
8976
"logging": {
9077
"sections": {
9178
"logging": "日誌",

0 commit comments

Comments
 (0)