mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Making modifications in an Entry creates a new History entry
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
|
||||||
using ModernKeePass.Interfaces;
|
using ModernKeePass.Interfaces;
|
||||||
using ModernKeePass.Services;
|
using ModernKeePass.Services;
|
||||||
using ModernKeePassLib;
|
using ModernKeePassLib;
|
||||||
@@ -148,11 +147,12 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var history = new List<EntryVm> {this};
|
var history = new Stack<EntryVm>();
|
||||||
foreach (var historyEntry in _pwEntry.History)
|
foreach (var historyEntry in _pwEntry.History)
|
||||||
{
|
{
|
||||||
history.Add(new EntryVm(historyEntry, ParentGroup) {IsSelected = false});
|
history.Push(new EntryVm(historyEntry, ParentGroup) {IsSelected = false});
|
||||||
}
|
}
|
||||||
|
history.Push(this);
|
||||||
|
|
||||||
return history;
|
return history;
|
||||||
}
|
}
|
||||||
@@ -164,6 +164,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
private readonly IDatabaseService _database;
|
private readonly IDatabaseService _database;
|
||||||
private readonly IResourceService _resource;
|
private readonly IResourceService _resource;
|
||||||
private bool _isEditMode;
|
private bool _isEditMode;
|
||||||
|
private bool _isDirty;
|
||||||
private bool _isRevealPassword;
|
private bool _isRevealPassword;
|
||||||
private double _passwordLength = 25;
|
private double _passwordLength = 25;
|
||||||
private bool _isVisible = true;
|
private bool _isVisible = true;
|
||||||
@@ -221,7 +222,13 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
private void SetEntryValue(string key, string newValue)
|
private void SetEntryValue(string key, string newValue)
|
||||||
{
|
{
|
||||||
|
if (!_isDirty)
|
||||||
|
{
|
||||||
|
_pwEntry.Touch(true);
|
||||||
|
_pwEntry?.CreateBackup(null);
|
||||||
|
}
|
||||||
_pwEntry?.Strings.Set(key, new ProtectedString(true, newValue));
|
_pwEntry?.Strings.Set(key, new ProtectedString(true, newValue));
|
||||||
|
_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MarkForDelete(string recycleBinTitle)
|
public void MarkForDelete(string recycleBinTitle)
|
||||||
@@ -264,10 +271,15 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
return _pwEntry;
|
return _pwEntry;
|
||||||
}
|
}
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
_isDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return IsSelected ? _resource.GetResourceValue("EntryCurrent") : _pwEntry.LastModificationTime.ToString("g");
|
return IsSelected ? _resource.GetResourceValue("EntryCurrent") : _pwEntry.LastModificationTime.ToString("g");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,7 @@ namespace ModernKeePass.Views
|
|||||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
NavigationHelper.OnNavigatedFrom(e);
|
NavigationHelper.OnNavigatedFrom(e);
|
||||||
|
Model.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Reference in New Issue
Block a user