fixed a few aes problems

This commit is contained in:
iAmAsval
2021-06-09 09:41:23 +02:00
parent 2bde70ff2d
commit d74f7b1372
3 changed files with 31 additions and 23 deletions

View File

@@ -64,28 +64,35 @@ namespace FModel.ViewModels
_keysFromSettings.MainKey = key;
}
else if (!_keysFromSettings.HasDynamicKeys)
{
HasChange = true;
_keysFromSettings.DynamicKeys = new List<DynamicKey>
{
new()
{
Key = key,
FileName = collection[e.CollectionIndex].Name,
Guid = collection[e.CollectionIndex].Guid.ToString()
}
};
}
else if (_keysFromSettings.DynamicKeys.FirstOrDefault(x => x.Guid == collection[e.CollectionIndex].Guid.ToString()) is { } d)
{
if (!HasChange)
HasChange = FixKey(d.Key) != key;
d.Key = key;
}
else
{
if (!_keysFromSettings.HasDynamicKeys)
HasChange = true;
_keysFromSettings.DynamicKeys.Add(new DynamicKey
{
HasChange = true;
_keysFromSettings.DynamicKeys = new[]
{
new DynamicKey
{
Key = key,
FileName = collection[e.CollectionIndex].Name,
Guid = collection[e.CollectionIndex].Guid.ToString()
}
};
}
else if (_keysFromSettings.DynamicKeys.FirstOrDefault(x => x.Guid == collection[e.CollectionIndex].Guid.ToString()) is { } d)
{
if (!HasChange)
HasChange = FixKey(d.Key) != key;
d.Key = key;
}
Key = key,
FileName = collection[e.CollectionIndex].Name,
Guid = collection[e.CollectionIndex].Guid.ToString()
});
}
}

View File

@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Collections.Generic;
using System.Diagnostics;
using J = Newtonsoft.Json.JsonPropertyAttribute;
namespace FModel.ViewModels.ApiEndpoints.Models
@@ -8,9 +9,9 @@ namespace FModel.ViewModels.ApiEndpoints.Models
{
[J("version")] public string Version { get; private set; }
[J("mainKey")] public string MainKey { get; set; }
[J("dynamicKeys")] public DynamicKey[] DynamicKeys { get; set; }
[J("dynamicKeys")] public List<DynamicKey> DynamicKeys { get; set; }
public bool HasDynamicKeys => DynamicKeys is {Length: > 0};
public bool HasDynamicKeys => DynamicKeys is {Count: > 0};
}
[DebuggerDisplay("{" + nameof(Key) + "}")]

View File

@@ -243,7 +243,7 @@ namespace FModel.ViewModels
await _threadWorkerView.Begin(cancellationToken =>
{
var aes = _apiEndpointView.BenbotApi.GetAesKeys(cancellationToken);
if (aes == null) return;
if (aes?.MainKey == null && aes?.DynamicKeys == null && aes?.Version == null) return;
UserSettings.Default.AesKeys[Game] = aes;
});