Skip to content

Commit f939abb

Browse files
committed
Remove need for saving to settings file by getting status dynamically
1 parent f933f9d commit f939abb

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

Wox.Infrastructure/UserSettings/Settings.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ public string QuerySearchPrecisionString
7777
public bool DontPromptUpdateMsg { get; set; }
7878
public bool EnableUpdateLog { get; set; }
7979

80-
public bool PortableMode { get; set; } = DataLocation.PortableDataLocationInUse();
81-
8280
public bool StartWoxOnSystemStartup { get; set; } = true;
8381
public bool HideOnStartup { get; set; }
8482
bool _hideNotifyIcon { get; set; }

Wox/ViewModel/SettingWindowViewModel.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public SettingWindowViewModel(Updater updater, IPortable portable)
3838
OnPropertyChanged(nameof(ActivatedTimes));
3939
}
4040
};
41-
_portableMode = Settings.PortableMode;
4241
}
4342

4443
public Settings Settings { get; set; }
@@ -48,26 +47,33 @@ public async void UpdateApp()
4847
await _updater.UpdateApp(false);
4948
}
5049

51-
private bool _portableMode;
50+
// This is only required to set at startup. When portable mode enabled/disabled a restart is always required
51+
private bool _portableMode = DataLocation.PortableDataLocationInUse();
5252
public bool PortableMode
5353
{
5454
get { return _portableMode; }
5555
set
5656
{
5757
if (!_portable.CanUpdatePortability())
5858
return;
59-
60-
_portableMode = value;
6159

62-
Settings.PortableMode = value;
63-
Save();
64-
PortabilityUpdate(value);
60+
bool switchToPortable;
61+
if(DataLocation.PortableDataLocationInUse())
62+
{
63+
switchToPortable = false;
64+
}
65+
else
66+
{
67+
switchToPortable = true;
68+
}
69+
70+
PortabilityUpdate(switchToPortable);
6571
}
6672
}
6773

68-
private void PortabilityUpdate(bool enabled)
74+
private void PortabilityUpdate(bool enablePortableMode)
6975
{
70-
if (enabled)
76+
if (enablePortableMode)
7177
{
7278
_portable.EnablePortableMode();
7379
}

0 commit comments

Comments
 (0)