diff --git a/Wox.Infrastructure/UserSettings/Settings.cs b/Wox.Infrastructure/UserSettings/Settings.cs index 9d8e46ae6..7714768f0 100644 --- a/Wox.Infrastructure/UserSettings/Settings.cs +++ b/Wox.Infrastructure/UserSettings/Settings.cs @@ -77,8 +77,6 @@ namespace Wox.Infrastructure.UserSettings public bool DontPromptUpdateMsg { get; set; } public bool EnableUpdateLog { get; set; } - public bool PortableMode { get; set; } = DataLocation.PortableDataLocationInUse(); - public bool StartWoxOnSystemStartup { get; set; } = true; public bool HideOnStartup { get; set; } bool _hideNotifyIcon { get; set; } diff --git a/Wox/ViewModel/SettingWindowViewModel.cs b/Wox/ViewModel/SettingWindowViewModel.cs index 1e22635e5..c16d619cd 100644 --- a/Wox/ViewModel/SettingWindowViewModel.cs +++ b/Wox/ViewModel/SettingWindowViewModel.cs @@ -38,7 +38,6 @@ namespace Wox.ViewModel OnPropertyChanged(nameof(ActivatedTimes)); } }; - _portableMode = Settings.PortableMode; } public Settings Settings { get; set; } @@ -48,7 +47,8 @@ namespace Wox.ViewModel await _updater.UpdateApp(false); } - private bool _portableMode; + // This is only required to set at startup. When portable mode enabled/disabled a restart is always required + private bool _portableMode = DataLocation.PortableDataLocationInUse(); public bool PortableMode { get { return _portableMode; } @@ -56,18 +56,24 @@ namespace Wox.ViewModel { if (!_portable.CanUpdatePortability()) return; - - _portableMode = value; - Settings.PortableMode = value; - Save(); - PortabilityUpdate(value); + bool switchToPortable; + if(DataLocation.PortableDataLocationInUse()) + { + switchToPortable = false; + } + else + { + switchToPortable = true; + } + + PortabilityUpdate(switchToPortable); } } - private void PortabilityUpdate(bool enabled) + private void PortabilityUpdate(bool enablePortableMode) { - if (enabled) + if (enablePortableMode) { _portable.EnablePortableMode(); }