Renamed types to more descriptive name
This commit is contained in:
@@ -28,7 +28,7 @@ class Program
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<IPasswordStoreService, PasswordStoreService>();
|
||||
services.AddSingleton<IRepository, JsonRepository>();
|
||||
services.AddSingleton<IBookmarksRepository, BookmarksRepository>();
|
||||
services.AddSingleton<ISecretService, SecretService>();
|
||||
return services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Keychain.UI;
|
||||
|
||||
public class AddShortcutWindow
|
||||
{
|
||||
private readonly PasswordStoreShortcutCollection shortcuts;
|
||||
private readonly BookmarkCollection shortcuts;
|
||||
public Dialog Dialog { get; }
|
||||
private const string dialogId = "add_shortcut_dialog";
|
||||
private Gtk.Button? closeButton;
|
||||
@@ -21,7 +21,7 @@ public class AddShortcutWindow
|
||||
private Gtk.Button? saveButton;
|
||||
private const string saveButtonId = "save_button";
|
||||
|
||||
public AddShortcutWindow(PasswordStoreShortcutCollection shortcuts)
|
||||
public AddShortcutWindow(BookmarkCollection shortcuts)
|
||||
{
|
||||
this.shortcuts = shortcuts;
|
||||
var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml");
|
||||
|
||||
@@ -26,7 +26,7 @@ public partial class MainWindow
|
||||
BindUIElements();
|
||||
|
||||
// Initialize the observable collection with property binding
|
||||
shortcuts = new PasswordStoreShortcutCollection(shortcutsGroup, passwordStoreService);
|
||||
shortcuts = new BookmarkCollection(shortcutsGroup, passwordStoreService);
|
||||
if (shortcuts.Count == 0)
|
||||
{
|
||||
LoadDefaultShortcuts();
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class MainWindow
|
||||
private readonly IPasswordStoreService passwordStoreService;
|
||||
|
||||
private PreferencesGroup shortcutsGroup;
|
||||
private PasswordStoreShortcutCollection shortcuts;
|
||||
private BookmarkCollection shortcuts;
|
||||
private const string shortcutsGroupId = "shortcuts_group";
|
||||
private const string addShortcutButtonId = "add_shortcut_button";
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ using Logic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStoreViewModel>
|
||||
public class BookmarkCollection : ObservableCollection<BookmarkViewModel>
|
||||
{
|
||||
private readonly IPasswordStoreService _passwordStoreService;
|
||||
|
||||
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()
|
||||
{
|
||||
this.shortcutsGroup = shortcutsGroup;
|
||||
@@ -23,7 +23,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
|
||||
// Initialize from existing stores
|
||||
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)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
foreach (PasswordStoreViewModel item in e.NewItems)
|
||||
foreach (BookmarkViewModel item in e.NewItems)
|
||||
{
|
||||
var row = CreateShortcutRow(item);
|
||||
itemToRowMap[item] = row;
|
||||
@@ -44,7 +44,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
foreach (PasswordStoreViewModel item in e.OldItems)
|
||||
foreach (BookmarkViewModel item in e.OldItems)
|
||||
{
|
||||
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();
|
||||
UpdateRowFromItem(shortcut, ref row);
|
||||
@@ -78,7 +78,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
|
||||
return row;
|
||||
}
|
||||
|
||||
private void UpdateRowFromItem(PasswordStoreViewModel shortcut, ref ActionRow row)
|
||||
private void UpdateRowFromItem(BookmarkViewModel shortcut, ref ActionRow row)
|
||||
{
|
||||
row.SetTitle(shortcut.DisplayName);
|
||||
row.SetSubtitle(shortcut.Path);
|
||||
@@ -93,7 +93,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
|
||||
|
||||
public void Add(string path, string? displayName = null)
|
||||
{
|
||||
PasswordStoreViewModel item = new PasswordStoreViewModel(path, displayName);
|
||||
BookmarkViewModel item = new BookmarkViewModel(path, displayName);
|
||||
Add(item);
|
||||
_passwordStoreService.Create(item.Model);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Models;
|
||||
|
||||
namespace Keychain.ViewModels;
|
||||
|
||||
public class PasswordStoreViewModel : INotifyPropertyChanged
|
||||
public class BookmarkViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private PasswordStore _model;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
@@ -20,12 +20,12 @@ public class PasswordStoreViewModel : INotifyPropertyChanged
|
||||
|
||||
public PasswordStore Model { get => _model; }
|
||||
|
||||
public PasswordStoreViewModel(PasswordStore item)
|
||||
public BookmarkViewModel(PasswordStore item)
|
||||
{
|
||||
_model = item;
|
||||
}
|
||||
|
||||
public PasswordStoreViewModel(string path, string? displayName = "New Shortcut")
|
||||
public BookmarkViewModel(string path, string? displayName = "New Shortcut")
|
||||
{
|
||||
_model = new PasswordStore
|
||||
{
|
||||
@@ -5,10 +5,10 @@ namespace Logic;
|
||||
|
||||
public class PasswordStoreService : IPasswordStoreService
|
||||
{
|
||||
private readonly IRepository repository;
|
||||
private readonly IBookmarksRepository repository;
|
||||
private readonly ISecretService secretService;
|
||||
|
||||
public PasswordStoreService(IRepository repository, ISecretService secretService)
|
||||
public PasswordStoreService(IBookmarksRepository repository, ISecretService secretService)
|
||||
{
|
||||
this.repository = repository;
|
||||
this.secretService = secretService;
|
||||
|
||||
@@ -3,7 +3,7 @@ using Models;
|
||||
|
||||
namespace Repository;
|
||||
|
||||
public class JsonRepository : IRepository, IDisposable
|
||||
public class BookmarksRepository : IBookmarksRepository, IDisposable
|
||||
{
|
||||
private const string _appName = "Keychain";
|
||||
private const string fileName = "password_stores.json";
|
||||
@@ -13,7 +13,7 @@ public class JsonRepository : IRepository, IDisposable
|
||||
private List<PasswordStore> _cache;
|
||||
private bool _cacheAhead;
|
||||
|
||||
public JsonRepository()
|
||||
public BookmarksRepository()
|
||||
{
|
||||
string? xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
|
||||
string dataHome;
|
||||
@@ -3,7 +3,7 @@ using Models;
|
||||
|
||||
namespace Repository;
|
||||
|
||||
public interface IRepository
|
||||
public interface IBookmarksRepository
|
||||
{
|
||||
List<PasswordStore> GetAll();
|
||||
void Create(PasswordStore item);
|
||||
Reference in New Issue
Block a user