mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Added the option to close DB without saving
Changed the way recent files are retrieved Stopped showing the DB Closed exception on suspend Reordering entries works Moved code from infra to application Cleanup
This commit is contained in:
@@ -119,7 +119,7 @@
|
||||
<Compile Include="Group\Commands\AddGroup\AddGroupCommand.cs" />
|
||||
<Compile Include="Group\Commands\CreateEntry\CreateEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\CreateGroup\CreateGroupCommand.cs" />
|
||||
<Compile Include="Group\Commands\InsertEntry\InsertEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\MoveEntry\MoveEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\RemoveEntry\RemoveEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\RemoveGroup\RemoveGroupCommand.cs" />
|
||||
<Compile Include="Group\Commands\SortEntries\SortEntriesCommand.cs" />
|
||||
|
@@ -27,7 +27,7 @@ namespace ModernKeePass.Application.Common.Interfaces
|
||||
void CloseDatabase();
|
||||
|
||||
Task AddEntry(string parentGroupId, string entryId);
|
||||
Task InsertEntry(string parentGroupId, string entryId, int index);
|
||||
Task MoveEntry(string parentGroupId, string entryId, int index);
|
||||
Task AddGroup(string parentGroupId, string groupId);
|
||||
void UpdateEntry(string entryId, string fieldName, object fieldValue);
|
||||
void UpdateGroup(string groupId);
|
||||
|
@@ -8,7 +8,7 @@ namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
int EntryCount { get; }
|
||||
Task<FileInfo> Get(string token, bool updateAccessTime = false);
|
||||
Task<IEnumerable<FileInfo>> GetAll();
|
||||
IEnumerable<FileInfo> GetAll();
|
||||
Task Add(FileInfo recentItem);
|
||||
void ClearAll();
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Domain.Common;
|
||||
|
||||
namespace ModernKeePass.Application.Database.Queries.GetDatabase
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace ModernKeePass.Application.Database.Queries.GetDatabase
|
||||
database.Name = _databaseProxy.Name;
|
||||
database.RootGroupId = _databaseProxy.RootGroupId;
|
||||
database.IsRecycleBinEnabled = _databaseProxy.IsRecycleBinEnabled;
|
||||
database.RecycleBinId = _databaseProxy.RecycleBinId;
|
||||
database.RecycleBinId = _databaseProxy.RecycleBinId == Constants.EmptyId ? null : _databaseProxy.RecycleBinId;
|
||||
database.Compression = _databaseProxy.Compression;
|
||||
database.CipherId = _databaseProxy.CipherId;
|
||||
database.KeyDerivationId = _databaseProxy.KeyDerivationId;
|
||||
|
@@ -5,28 +5,28 @@ using ModernKeePass.Application.Entry.Models;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Group.Commands.InsertEntry
|
||||
namespace ModernKeePass.Application.Group.Commands.MoveEntry
|
||||
{
|
||||
public class InsertEntryCommand : IRequest
|
||||
public class MoveEntryCommand : IRequest
|
||||
{
|
||||
public GroupVm ParentGroup { get; set; }
|
||||
public EntryVm Entry { get; set; }
|
||||
public int Index { get; set; }
|
||||
|
||||
public class InsertEntryCommandHandler : IAsyncRequestHandler<InsertEntryCommand>
|
||||
public class MoveEntryCommandHandler : IAsyncRequestHandler<MoveEntryCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public InsertEntryCommandHandler(IDatabaseProxy database)
|
||||
public MoveEntryCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task Handle(InsertEntryCommand message)
|
||||
public async Task Handle(MoveEntryCommand message)
|
||||
{
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
await _database.InsertEntry(message.ParentGroup.Id, message.Entry.Id, message.Index);
|
||||
await _database.MoveEntry(message.ParentGroup.Id, message.Entry.Id, message.Index);
|
||||
message.ParentGroup.Entries.Insert(message.Index, message.Entry);
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Common;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Parameters.Commands.SetRecycleBin
|
||||
@@ -19,8 +20,8 @@ namespace ModernKeePass.Application.Parameters.Commands.SetRecycleBin
|
||||
|
||||
public void Handle(SetRecycleBinCommand message)
|
||||
{
|
||||
if (_database.IsOpen) _database.RecycleBinId = message.RecycleBinId;
|
||||
else throw new DatabaseClosedException();
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
_database.RecycleBinId = message.RecycleBinId ?? Constants.EmptyId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user