From 99a3a7cc5c24b71341f2888bef62dfc2ae14bfd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Wed, 29 Oct 2025 13:23:56 +0100 Subject: [PATCH] Renamed type to more descriptive name --- src/App/ViewModels/Bookmark/BookmarkViewModel.cs | 8 ++++---- src/Logic/CollectionsService.cs | 12 ++++++------ src/Logic/ICollectionsService.cs | 10 +++++----- src/Models/{PasswordStore.cs => Bookmark.cs} | 2 +- src/Repository/BookmarksRepository.cs | 10 +++++----- src/Repository/IBookmarksRepository.cs | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) rename src/Models/{PasswordStore.cs => Bookmark.cs} (83%) diff --git a/src/App/ViewModels/Bookmark/BookmarkViewModel.cs b/src/App/ViewModels/Bookmark/BookmarkViewModel.cs index 77ed061..813fa1c 100644 --- a/src/App/ViewModels/Bookmark/BookmarkViewModel.cs +++ b/src/App/ViewModels/Bookmark/BookmarkViewModel.cs @@ -5,7 +5,7 @@ namespace Keychain.ViewModels; public class BookmarkViewModel : INotifyPropertyChanged { - private PasswordStore _model; + private Bookmark _model; public event PropertyChangedEventHandler? PropertyChanged; public string? DisplayName @@ -18,16 +18,16 @@ public class BookmarkViewModel : INotifyPropertyChanged get => _model.Path; } - public PasswordStore Model { get => _model; } + public Bookmark Model { get => _model; } - public BookmarkViewModel(PasswordStore item) + public BookmarkViewModel(Bookmark item) { _model = item; } public BookmarkViewModel(string path, string? displayName = "New Shortcut") { - _model = new PasswordStore + _model = new Bookmark { DisplayName = displayName, Path = path, diff --git a/src/Logic/CollectionsService.cs b/src/Logic/CollectionsService.cs index 28464c7..d4988ae 100644 --- a/src/Logic/CollectionsService.cs +++ b/src/Logic/CollectionsService.cs @@ -14,7 +14,7 @@ public class CollectionsService : ICollectionsService this.secretService = secretService; } - public bool Create(PasswordStore item) + public bool Create(Bookmark item) { if (secretService.CreateCollection(item.DisplayName ?? item.Path)) { @@ -30,26 +30,26 @@ public class CollectionsService : ICollectionsService repository.Delete(ID); } - public void Delete(PasswordStore item) + public void Delete(Bookmark item) { Delete(item.ID); } - public void Edit(uint ID, PasswordStore newItem) + public void Edit(uint ID, Bookmark newItem) { repository.Delete(ID); newItem.ID = ID; repository.Create(newItem); } - public PasswordStore Get(uint ID) + public Bookmark Get(uint ID) { return repository.GetAll().FirstOrDefault(i => i.ID == ID) ?? throw new Exception("Item not found"); } - public IEnumerable GetAll() + public IEnumerable GetAll() { - List jsonResults = repository.GetAll(); + List jsonResults = repository.GetAll(); //Validate against actual secret collections var collections = secretService.GetCollections() ?? Enumerable.Empty(); diff --git a/src/Logic/ICollectionsService.cs b/src/Logic/ICollectionsService.cs index 446cea1..b9160e4 100644 --- a/src/Logic/ICollectionsService.cs +++ b/src/Logic/ICollectionsService.cs @@ -4,10 +4,10 @@ namespace Logic; public interface ICollectionsService { - IEnumerable GetAll(); - PasswordStore Get(uint ID); + IEnumerable GetAll(); + Bookmark Get(uint ID); void Delete(uint ID); - void Delete(PasswordStore item); - bool Create(PasswordStore item); - void Edit(uint ID, PasswordStore newItem); + void Delete(Bookmark item); + bool Create(Bookmark item); + void Edit(uint ID, Bookmark newItem); } diff --git a/src/Models/PasswordStore.cs b/src/Models/Bookmark.cs similarity index 83% rename from src/Models/PasswordStore.cs rename to src/Models/Bookmark.cs index e46348a..d518fd6 100644 --- a/src/Models/PasswordStore.cs +++ b/src/Models/Bookmark.cs @@ -1,6 +1,6 @@ namespace Models; -public class PasswordStore +public class Bookmark { public uint ID { get; set; } public string Path { get; set; } diff --git a/src/Repository/BookmarksRepository.cs b/src/Repository/BookmarksRepository.cs index 0d82258..533ceee 100644 --- a/src/Repository/BookmarksRepository.cs +++ b/src/Repository/BookmarksRepository.cs @@ -10,7 +10,7 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable private uint _autoIncrementedId; private readonly string _filePath; - private List _cache; + private List _cache; private bool _cacheAhead; public BookmarksRepository() @@ -41,14 +41,14 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable private void ReadAllFromFile() { - var items = new List(); + var items = new List(); if (File.Exists(_filePath)) { try { string json = File.ReadAllText(_filePath); - items = JsonSerializer.Deserialize>(json) ?? new List(); + items = JsonSerializer.Deserialize>(json) ?? new List(); } catch (JsonException e) { @@ -68,7 +68,7 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable _cacheAhead = false; } - public List GetAll() + public List GetAll() { return _cache; } @@ -98,7 +98,7 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable } } - public void Create(PasswordStore item) + public void Create(Bookmark item) { item.ID = ++_autoIncrementedId; _cache.Add(item); diff --git a/src/Repository/IBookmarksRepository.cs b/src/Repository/IBookmarksRepository.cs index 75c98c9..a9a81f7 100644 --- a/src/Repository/IBookmarksRepository.cs +++ b/src/Repository/IBookmarksRepository.cs @@ -5,7 +5,7 @@ namespace Repository; public interface IBookmarksRepository { - List GetAll(); - void Create(PasswordStore item); + List GetAll(); + void Create(Bookmark item); void Delete(uint ID); } \ No newline at end of file