From 29be091a4bb8dcf960ced6aea5b0ffa9a646a5cf Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 4 Aug 2025 14:18:04 -0600 Subject: [PATCH] Fix cross-thread error on AccoundSettings.Saved event --- Source/LibationAvalonia/ViewModels/MainVM.Import.cs | 5 +++-- Source/LibationWinForms/Form1.ScanManual.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/LibationAvalonia/ViewModels/MainVM.Import.cs b/Source/LibationAvalonia/ViewModels/MainVM.Import.cs index fa8b6377..9947a488 100644 --- a/Source/LibationAvalonia/ViewModels/MainVM.Import.cs +++ b/Source/LibationAvalonia/ViewModels/MainVM.Import.cs @@ -68,7 +68,8 @@ namespace LibationAvalonia.ViewModels MainWindow.Loaded += (_, _) => { refreshImportMenu(); - AccountsSettingsPersister.Saved += refreshImportMenu; + AccountsSettingsPersister.Saved += (_, _) + => Avalonia.Threading.Dispatcher.UIThread.Invoke(refreshImportMenu); }; AutoScanChecked = Configuration.Instance.AutoScan; @@ -222,7 +223,7 @@ namespace LibationAvalonia.ViewModels } } - private void refreshImportMenu(object? _ = null, EventArgs? __ = null) + private void refreshImportMenu() { using var persister = AudibleApiStorage.GetAccountsSettingsPersister(); AccountsCount = persister.AccountsSettings.Accounts.Count; diff --git a/Source/LibationWinForms/Form1.ScanManual.cs b/Source/LibationWinForms/Form1.ScanManual.cs index 3aebb56d..93214d63 100644 --- a/Source/LibationWinForms/Form1.ScanManual.cs +++ b/Source/LibationWinForms/Form1.ScanManual.cs @@ -16,7 +16,7 @@ namespace LibationWinForms private void Configure_ScanManual() { this.Load += refreshImportMenu; - AccountsSettingsPersister.Saved += refreshImportMenu; + AccountsSettingsPersister.Saved += (_, _) => Invoke(refreshImportMenu, null, null); } private void refreshImportMenu(object _, EventArgs __)