Skip to content

Commit 3cb8e98

Browse files
author
Mohammod Al Amin Ashik
committed
fix: Only update auto-launch when value changes and fix switch visibility
- Check current auto-launch state before calling enable/disable - Only modify OS auto-launch setting when the value actually changes - Add proper flex layout with gap-4 and min-w-0 to prevent switch overflow - Add flex-shrink-0 to icons and switches to prevent compression - This fixes 'file not found' errors and missing switches in UI
1 parent b0fa549 commit 3cb8e98

3 files changed

Lines changed: 26 additions & 20 deletions

File tree

apps/desktop/src-tauri/src/commands/settings.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,23 @@ pub async fn update_startup_settings(
7777

7878
let settings_repo = &app_state.settings_repository;
7979

80-
// Update auto-launch in OS
81-
if settings.auto_launch {
82-
manager
83-
.enable()
84-
.map_err(|e| format!("Failed to enable auto-launch: {}", e))?;
85-
info!("[Settings] Auto-launch enabled");
80+
// Check if auto-launch setting has changed before modifying OS
81+
let current_auto_launch = manager.is_enabled().unwrap_or(false);
82+
83+
if settings.auto_launch != current_auto_launch {
84+
if settings.auto_launch {
85+
manager
86+
.enable()
87+
.map_err(|e| format!("Failed to enable auto-launch: {}", e))?;
88+
info!("[Settings] Auto-launch enabled");
89+
} else {
90+
manager
91+
.disable()
92+
.map_err(|e| format!("Failed to disable auto-launch: {}", e))?;
93+
info!("[Settings] Auto-launch disabled");
94+
}
8695
} else {
87-
manager
88-
.disable()
89-
.map_err(|e| format!("Failed to disable auto-launch: {}", e))?;
90-
info!("[Settings] Auto-launch disabled");
96+
info!("[Settings] Auto-launch unchanged, skipping OS update");
9197
}
9298

9399
// Update other settings in database

apps/desktop/src/features/settings/SettingsPage.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ export function SettingsPage() {
139139
</div>
140140
) : (
141141
<div className="space-y-6">
142-
<div className="flex items-center justify-between">
143-
<div className="flex items-start gap-3 flex-1">
144-
<Power className="h-5 w-5 mt-0.5 text-[rgb(var(--muted))]" />
142+
<div className="flex items-center justify-between gap-4">
143+
<div className="flex items-start gap-3 flex-1 min-w-0">
144+
<Power className="h-5 w-5 mt-0.5 text-[rgb(var(--muted))] flex-shrink-0" />
145145
<div>
146146
<label className="text-sm font-medium">Launch at Startup</label>
147147
<p className="text-xs text-[rgb(var(--muted))] mt-1">
@@ -160,9 +160,9 @@ export function SettingsPage() {
160160
/>
161161
</div>
162162

163-
<div className="flex items-center justify-between">
164-
<div className="flex items-start gap-3 flex-1">
165-
<Minimize2 className="h-5 w-5 mt-0.5 text-[rgb(var(--muted))]" />
163+
<div className="flex items-center justify-between gap-4">
164+
<div className="flex items-start gap-3 flex-1 min-w-0">
165+
<Minimize2 className="h-5 w-5 mt-0.5 text-[rgb(var(--muted))] flex-shrink-0" />
166166
<div>
167167
<label className="text-sm font-medium">Start Minimized</label>
168168
<p className="text-xs text-[rgb(var(--muted))] mt-1">
@@ -181,9 +181,9 @@ export function SettingsPage() {
181181
/>
182182
</div>
183183

184-
<div className="flex items-center justify-between">
185-
<div className="flex items-start gap-3 flex-1">
186-
<XCircle className="h-5 w-5 mt-0.5 text-[rgb(var(--muted))]" />
184+
<div className="flex items-center justify-between gap-4">
185+
<div className="flex items-start gap-3 flex-1 min-w-0">
186+
<XCircle className="h-5 w-5 mt-0.5 text-[rgb(var(--muted))] flex-shrink-0" />
187187
<div>
188188
<label className="text-sm font-medium">Close to Tray</label>
189189
<p className="text-xs text-[rgb(var(--muted))] mt-1">

packages/ui/src/components/common/Switch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function Switch({
3636
onClick={handleClick}
3737
data-testid={testId}
3838
className={cn(
39-
'relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-[rgb(var(--primary))] focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
39+
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-[rgb(var(--primary))] focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
4040
checked ? 'bg-[rgb(var(--primary))]' : 'bg-surface-secondary',
4141
className
4242
)}

0 commit comments

Comments
 (0)