mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Save error is now handled via Messenger instead of unhandled exception handler (which didn't work)
Save as actually works now WIP Styles Code cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using GalaSoft.MvvmLight.Views;
|
||||
using MediatR;
|
||||
using Messages;
|
||||
@@ -15,16 +16,31 @@ namespace ModernKeePass.ViewModels
|
||||
private readonly IMediator _mediator;
|
||||
private readonly ISettingsProxy _settings;
|
||||
private readonly INavigationService _navigation;
|
||||
private readonly IFileProxy _file;
|
||||
|
||||
public RelayCommand CreateDatabaseFileCommand { get; }
|
||||
|
||||
public NewVm(IMediator mediator, IRecentProxy recent, ISettingsProxy settings, INavigationService navigation)
|
||||
public NewVm(IMediator mediator, ISettingsProxy settings, INavigationService navigation, IFileProxy file): base(file)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_settings = settings;
|
||||
_navigation = navigation;
|
||||
_file = file;
|
||||
|
||||
CreateDatabaseFileCommand = new RelayCommand(async () => await CreateDatabaseFile());
|
||||
|
||||
MessengerInstance.Register<CredentialsSetMessage>(this, async m => await TryCreateDatabase(m));
|
||||
}
|
||||
|
||||
private async Task CreateDatabaseFile()
|
||||
{
|
||||
// TODO: get these from resource
|
||||
var file = await _file.CreateFile("New Database", Domain.Common.Constants.Extensions.Kdbx, "KeePass 2.x database", true);
|
||||
Token = file.Id;
|
||||
Path = file.Path;
|
||||
Name = file.Name;
|
||||
}
|
||||
|
||||
private async Task TryCreateDatabase(CredentialsSetMessage message)
|
||||
{
|
||||
var database = await _mediator.Send(new GetDatabaseQuery());
|
||||
@@ -45,7 +61,7 @@ namespace ModernKeePass.ViewModels
|
||||
Password = message.Password,
|
||||
Name = "ModernKeePass",
|
||||
Version = _settings.GetSetting(Constants.Settings.DefaultFileFormat, "4"),
|
||||
CreateSampleData = _settings.GetSetting<bool>(Constants.Settings.Sample, true)
|
||||
CreateSampleData = _settings.GetSetting(Constants.Settings.Sample, true)
|
||||
});
|
||||
|
||||
var database = await _mediator.Send(new GetDatabaseQuery());
|
||||
|
Reference in New Issue
Block a user