Remove need for saving to settings file by getting status dynamically

This commit is contained in:
Jeremy Wu 2020-03-08 14:50:06 +11:00
parent f933f9d10c
commit f939abb6e7
2 changed files with 15 additions and 11 deletions

View file

@ -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; }

View file

@ -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();
}