mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00

Refactor the Database Service (no more enum, ...) Restored the Donate page with Paypal web page Added (but not working) MS App Center integration Corrected tests accordingly WIP AOP to detect database changes
51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Threading.Tasks;
|
|
using ModernKeePass.Interfaces;
|
|
using Windows.Storage;
|
|
using Windows.Storage.AccessCache;
|
|
using ModernKeePass.ViewModels;
|
|
|
|
namespace ModernKeePass.Services
|
|
{
|
|
public class RecentService : SingletonServiceBase<RecentService>, IRecentService
|
|
{
|
|
private readonly StorageItemMostRecentlyUsedList _mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
|
|
|
public int EntryCount => _mru.Entries.Count;
|
|
|
|
public ObservableCollection<IRecentItem> GetAllFiles(bool removeIfNonExistant = true)
|
|
{
|
|
var result = new ObservableCollection<IRecentItem>();
|
|
foreach (var entry in _mru.Entries)
|
|
{
|
|
try
|
|
{
|
|
var file = _mru.GetFileAsync(entry.Token, AccessCacheOptions.SuppressAccessTimeUpdate).GetAwaiter().GetResult();
|
|
result.Add(new RecentItemVm(entry.Token, entry.Metadata, file));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
if (removeIfNonExistant) _mru.Remove(entry.Token);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public void Add(IStorageItem file, string metadata)
|
|
{
|
|
_mru.Add(file, metadata);
|
|
}
|
|
|
|
public void ClearAll()
|
|
{
|
|
_mru.Clear();
|
|
}
|
|
|
|
public async Task<IStorageItem> GetFileAsync(string token)
|
|
{
|
|
return await _mru.GetFileAsync(token);
|
|
}
|
|
}
|
|
}
|