Renamed types to more descriptive name

This commit is contained in:
TypoMustakes
2025-10-28 12:05:35 +01:00
parent 3a17961c5c
commit 0dc6d8432a
11 changed files with 22 additions and 22 deletions

View File

@@ -28,7 +28,7 @@ class Program
{ {
var services = new ServiceCollection(); var services = new ServiceCollection();
services.AddSingleton<IPasswordStoreService, PasswordStoreService>(); services.AddSingleton<IPasswordStoreService, PasswordStoreService>();
services.AddSingleton<IRepository, JsonRepository>(); services.AddSingleton<IBookmarksRepository, BookmarksRepository>();
services.AddSingleton<ISecretService, SecretService>(); services.AddSingleton<ISecretService, SecretService>();
return services.BuildServiceProvider(); return services.BuildServiceProvider();
} }

View File

@@ -5,7 +5,7 @@ namespace Keychain.UI;
public class AddShortcutWindow public class AddShortcutWindow
{ {
private readonly PasswordStoreShortcutCollection shortcuts; private readonly BookmarkCollection shortcuts;
public Dialog Dialog { get; } public Dialog Dialog { get; }
private const string dialogId = "add_shortcut_dialog"; private const string dialogId = "add_shortcut_dialog";
private Gtk.Button? closeButton; private Gtk.Button? closeButton;
@@ -21,7 +21,7 @@ public class AddShortcutWindow
private Gtk.Button? saveButton; private Gtk.Button? saveButton;
private const string saveButtonId = "save_button"; private const string saveButtonId = "save_button";
public AddShortcutWindow(PasswordStoreShortcutCollection shortcuts) public AddShortcutWindow(BookmarkCollection shortcuts)
{ {
this.shortcuts = shortcuts; this.shortcuts = shortcuts;
var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml"); var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml");

View File

@@ -26,7 +26,7 @@ public partial class MainWindow
BindUIElements(); BindUIElements();
// Initialize the observable collection with property binding // Initialize the observable collection with property binding
shortcuts = new PasswordStoreShortcutCollection(shortcutsGroup, passwordStoreService); shortcuts = new BookmarkCollection(shortcutsGroup, passwordStoreService);
if (shortcuts.Count == 0) if (shortcuts.Count == 0)
{ {
LoadDefaultShortcuts(); LoadDefaultShortcuts();

View File

@@ -10,7 +10,7 @@ public partial class MainWindow
private readonly IPasswordStoreService passwordStoreService; private readonly IPasswordStoreService passwordStoreService;
private PreferencesGroup shortcutsGroup; private PreferencesGroup shortcutsGroup;
private PasswordStoreShortcutCollection shortcuts; private BookmarkCollection shortcuts;
private const string shortcutsGroupId = "shortcuts_group"; private const string shortcutsGroupId = "shortcuts_group";
private const string addShortcutButtonId = "add_shortcut_button"; private const string addShortcutButtonId = "add_shortcut_button";

View File

@@ -6,14 +6,14 @@ using Logic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStoreViewModel> public class BookmarkCollection : ObservableCollection<BookmarkViewModel>
{ {
private readonly IPasswordStoreService _passwordStoreService; private readonly IPasswordStoreService _passwordStoreService;
private readonly PreferencesGroup shortcutsGroup; private readonly PreferencesGroup shortcutsGroup;
private Dictionary<PasswordStoreViewModel, ActionRow> itemToRowMap = new(); private Dictionary<BookmarkViewModel, ActionRow> itemToRowMap = new();
public PasswordStoreShortcutCollection(PreferencesGroup shortcutsGroup, IPasswordStoreService passwordStoreService) public BookmarkCollection(PreferencesGroup shortcutsGroup, IPasswordStoreService passwordStoreService)
: base() : base()
{ {
this.shortcutsGroup = shortcutsGroup; this.shortcutsGroup = shortcutsGroup;
@@ -23,7 +23,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
// Initialize from existing stores // Initialize from existing stores
foreach (var store in _passwordStoreService.GetAll()) foreach (var store in _passwordStoreService.GetAll())
{ {
Add(new PasswordStoreViewModel(store)); Add(new BookmarkViewModel(store));
} }
} }
@@ -32,7 +32,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
switch (e.Action) switch (e.Action)
{ {
case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Add:
foreach (PasswordStoreViewModel item in e.NewItems) foreach (BookmarkViewModel item in e.NewItems)
{ {
var row = CreateShortcutRow(item); var row = CreateShortcutRow(item);
itemToRowMap[item] = row; itemToRowMap[item] = row;
@@ -44,7 +44,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
break; break;
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:
foreach (PasswordStoreViewModel item in e.OldItems) foreach (BookmarkViewModel item in e.OldItems)
{ {
if (itemToRowMap.TryGetValue(item, out var row)) if (itemToRowMap.TryGetValue(item, out var row))
{ {
@@ -64,7 +64,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
} }
} }
private ActionRow CreateShortcutRow(PasswordStoreViewModel shortcut) private ActionRow CreateShortcutRow(BookmarkViewModel shortcut)
{ {
var row = new ActionRow(); var row = new ActionRow();
UpdateRowFromItem(shortcut, ref row); UpdateRowFromItem(shortcut, ref row);
@@ -78,7 +78,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
return row; return row;
} }
private void UpdateRowFromItem(PasswordStoreViewModel shortcut, ref ActionRow row) private void UpdateRowFromItem(BookmarkViewModel shortcut, ref ActionRow row)
{ {
row.SetTitle(shortcut.DisplayName); row.SetTitle(shortcut.DisplayName);
row.SetSubtitle(shortcut.Path); row.SetSubtitle(shortcut.Path);
@@ -93,7 +93,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
public void Add(string path, string? displayName = null) public void Add(string path, string? displayName = null)
{ {
PasswordStoreViewModel item = new PasswordStoreViewModel(path, displayName); BookmarkViewModel item = new BookmarkViewModel(path, displayName);
Add(item); Add(item);
_passwordStoreService.Create(item.Model); _passwordStoreService.Create(item.Model);
} }

View File

@@ -3,7 +3,7 @@ using Models;
namespace Keychain.ViewModels; namespace Keychain.ViewModels;
public class PasswordStoreViewModel : INotifyPropertyChanged public class BookmarkViewModel : INotifyPropertyChanged
{ {
private PasswordStore _model; private PasswordStore _model;
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
@@ -20,12 +20,12 @@ public class PasswordStoreViewModel : INotifyPropertyChanged
public PasswordStore Model { get => _model; } public PasswordStore Model { get => _model; }
public PasswordStoreViewModel(PasswordStore item) public BookmarkViewModel(PasswordStore item)
{ {
_model = item; _model = item;
} }
public PasswordStoreViewModel(string path, string? displayName = "New Shortcut") public BookmarkViewModel(string path, string? displayName = "New Shortcut")
{ {
_model = new PasswordStore _model = new PasswordStore
{ {

View File

@@ -5,10 +5,10 @@ namespace Logic;
public class PasswordStoreService : IPasswordStoreService public class PasswordStoreService : IPasswordStoreService
{ {
private readonly IRepository repository; private readonly IBookmarksRepository repository;
private readonly ISecretService secretService; private readonly ISecretService secretService;
public PasswordStoreService(IRepository repository, ISecretService secretService) public PasswordStoreService(IBookmarksRepository repository, ISecretService secretService)
{ {
this.repository = repository; this.repository = repository;
this.secretService = secretService; this.secretService = secretService;

View File

@@ -3,7 +3,7 @@ using Models;
namespace Repository; namespace Repository;
public class JsonRepository : IRepository, IDisposable public class BookmarksRepository : IBookmarksRepository, IDisposable
{ {
private const string _appName = "Keychain"; private const string _appName = "Keychain";
private const string fileName = "password_stores.json"; private const string fileName = "password_stores.json";
@@ -13,7 +13,7 @@ public class JsonRepository : IRepository, IDisposable
private List<PasswordStore> _cache; private List<PasswordStore> _cache;
private bool _cacheAhead; private bool _cacheAhead;
public JsonRepository() public BookmarksRepository()
{ {
string? xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME"); string? xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
string dataHome; string dataHome;

View File

@@ -3,7 +3,7 @@ using Models;
namespace Repository; namespace Repository;
public interface IRepository public interface IBookmarksRepository
{ {
List<PasswordStore> GetAll(); List<PasswordStore> GetAll();
void Create(PasswordStore item); void Create(PasswordStore item);