mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Load settings.
This commit is contained in:
@@ -23,9 +23,12 @@
|
||||
// Copyright © 2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace RomRepoMgr.ViewModels
|
||||
@@ -169,5 +172,35 @@ namespace RomRepoMgr.ViewModels
|
||||
MigratingDatabaseText = "Migrating database...";
|
||||
ExitButtonText = "Exit";
|
||||
}
|
||||
|
||||
internal void OnOpened() => Dispatcher.UIThread.Post(LoadSettings);
|
||||
|
||||
void LoadSettings() => Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.Settings.LoadSettings();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
// TODO: Log error
|
||||
Dispatcher.UIThread.Post(FailedLoadingSettings);
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Post(LoadDatabase);
|
||||
});
|
||||
|
||||
void FailedLoadingSettings()
|
||||
{
|
||||
LoadingSettingsUnknown = false;
|
||||
LoadingSettingsError = true;
|
||||
ExitVisible = true;
|
||||
}
|
||||
|
||||
void LoadDatabase()
|
||||
{
|
||||
LoadingSettingsUnknown = false;
|
||||
LoadingSettingsOk = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user