From 2953ba35ba591b7f18b6790b249ccbf45519aeeb Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Sun, 21 Jun 2026 22:46:05 +0200 Subject: [PATCH] refactor(ui): remove redundant "Open wallet from file" menu item The wizard already covers opening existing wallets; a separate file-picker entry in the menu duplicates that flow without adding value. Remove the menu item, its click handler, the OpenFromPath VM method, and the loc key. --- src/App/Localization/Loc.cs | 3 +- .../ViewModels/MainWindowViewModel.Wizard.cs | 35 ------------------- src/App/Views/MainView.axaml | 2 -- src/App/Views/MainView.axaml.cs | 19 ---------- 4 files changed, 1 insertion(+), 58 deletions(-) diff --git a/src/App/Localization/Loc.cs b/src/App/Localization/Loc.cs index 5274c51..1381f5b 100644 --- a/src/App/Localization/Loc.cs +++ b/src/App/Localization/Loc.cs @@ -45,8 +45,7 @@ public sealed class Loc // Menu it en es fr pt de ["menu.file"] = ["_File", "_File", "_Archivo", "_Fichier", "_Arquivo", "_Datei"], ["menu.file.new"] = ["Nuovo / ripristina wallet…", "New / restore wallet…", "Nuevo / restaurar wallet…", "Nouveau / restaurer le wallet…", "Novo / restaurar carteira…", "Neu / Wallet wiederherstellen…"], - ["menu.file.open"] = ["Apri wallet da file…", "Open wallet from file…", "Abrir wallet desde archivo…", "Ouvrir le wallet depuis un fichier…", "Abrir carteira de arquivo…", "Wallet aus Datei öffnen…"], - ["menu.file.close"] = ["Chiudi wallet", "Close wallet", "Cerrar wallet", "Fermer le wallet", "Fechar carteira", "Wallet schließen"], +["menu.file.close"] = ["Chiudi wallet", "Close wallet", "Cerrar wallet", "Fermer le wallet", "Fechar carteira", "Wallet schließen"], ["menu.file.quit"] = ["Esci", "Quit", "Salir", "Quitter", "Sair", "Beenden"], ["menu.net"] = ["_Rete", "_Network", "_Red", "_Réseau", "_Rede", "_Netzwerk"], ["menu.net.discover"] = ["Cerca altri server (peer)", "Discover servers (peers)", "Buscar otros servidores (peers)", "Rechercher d'autres serveurs (pairs)", "Procurar outros servidores (peers)", "Weitere Server suchen (Peers)"], diff --git a/src/App/ViewModels/MainWindowViewModel.Wizard.cs b/src/App/ViewModels/MainWindowViewModel.Wizard.cs index b24f458..156cf3d 100644 --- a/src/App/ViewModels/MainWindowViewModel.Wizard.cs +++ b/src/App/ViewModels/MainWindowViewModel.Wizard.cs @@ -477,41 +477,6 @@ public partial class MainWindowViewModel } } - public void OpenFromPath(string path) - { - var newLock = WalletLock.TryAcquire(path); - if (newLock is null) { StatusMessage = Loc.Tr("msg.wallet.locked"); return; } - - try - { - var doc = WalletStore.Load(path); - if (IsWalletOpen) - CloseWallet(); - OpenLoaded(doc, WalletLoader.ToAccount(doc), path, password: null, newLock); - } - catch (WrongPasswordException) - { - newLock.Dispose(); - if (IsWalletOpen) - CloseWallet(); - _pendingOpenPath = path; - WalletFileExists = true; - PasswordInput = ""; - SetupStep = StepOpen; - StatusMessage = ""; - } - catch (UnauthorizedAccessException) - { - newLock.Dispose(); - StatusMessage = Loc.Tr("msg.wallet.noaccess"); - } - catch (Exception ex) - { - newLock.Dispose(); - StatusMessage = $"Errore: {ex.Message}"; - } - } - [RelayCommand] private void NewWallet() { diff --git a/src/App/Views/MainView.axaml b/src/App/Views/MainView.axaml index 2e930f4..efb058d 100644 --- a/src/App/Views/MainView.axaml +++ b/src/App/Views/MainView.axaml @@ -31,8 +31,6 @@ - diff --git a/src/App/Views/MainView.axaml.cs b/src/App/Views/MainView.axaml.cs index bd14997..3404d2e 100644 --- a/src/App/Views/MainView.axaml.cs +++ b/src/App/Views/MainView.axaml.cs @@ -23,25 +23,6 @@ public partial class MainView : UserControl InitializeComponent(); } - private async void OnOpenWalletFileClick(object? sender, RoutedEventArgs e) - { - if (DataContext is not MainWindowViewModel vm) return; - if (TopLevel.GetTopLevel(this)?.StorageProvider is not { } storage) return; - - var files = await storage.OpenFilePickerAsync(new FilePickerOpenOptions - { - Title = "Apri file wallet", - AllowMultiple = false, - FileTypeFilter = - [ - new FilePickerFileType("Wallet Palladium") { Patterns = ["*.wallet.json", "*.json"] }, - ], - }); - - if (files.FirstOrDefault()?.TryGetLocalPath() is { } path) - vm.OpenFromPath(path); - } - private void OnHistoryRowDoubleTapped(object? sender, TappedEventArgs e) { if (sender is not ListBox lb || DataContext is not MainWindowViewModel vm) return;