Fixed the issue with RefreshIcon's call in the desktop version.

This commit is contained in:
2dust
2026-07-14 09:52:01 +08:00
parent 996eb51f9b
commit b9a1c129c4
2 changed files with 11 additions and 7 deletions

View File

@@ -45,8 +45,7 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
ViewModel.DispatcherRefreshIconInteraction.RegisterHandler(interaction => ViewModel.DispatcherRefreshIconInteraction.RegisterHandler(interaction =>
{ {
Dispatcher.UIThread.Post(RefreshIcon, Dispatcher.UIThread.Post(RefreshIcon, DispatcherPriority.Default);
DispatcherPriority.Default);
interaction.SetOutput(Unit.Default); interaction.SetOutput(Unit.Default);
}).DisposeWith(disposables); }).DisposeWith(disposables);
}); });
@@ -57,6 +56,9 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
{ {
cmbSystemProxy.Items.RemoveAt(cmbSystemProxy.Items.Count - 1); cmbSystemProxy.Items.RemoveAt(cmbSystemProxy.Items.Count - 1);
} }
// Because this view has not yet been initialized when DispatcherRefreshIconInteraction is first called.
RefreshIcon();
} }
private void RefreshIcon() private void RefreshIcon()

View File

@@ -71,16 +71,18 @@ public partial class StatusBarView
ViewModel.DispatcherRefreshIconInteraction.RegisterHandler(interaction => ViewModel.DispatcherRefreshIconInteraction.RegisterHandler(interaction =>
{ {
Application.Current?.Dispatcher.Invoke(async () => Application.Current?.Dispatcher.Invoke(async () => await RefreshIcon(), DispatcherPriority.Normal);
{
tbNotify.Icon = await WindowsManager.Instance.GetNotifyIcon(_config);
Application.Current.MainWindow?.Icon = WindowsManager.Instance.GetAppIcon(_config);
}, DispatcherPriority.Normal);
interaction.SetOutput(Unit.Default); interaction.SetOutput(Unit.Default);
}).DisposeWith(disposables); }).DisposeWith(disposables);
}); });
} }
private async Task RefreshIcon()
{
tbNotify.Icon = await WindowsManager.Instance.GetNotifyIcon(_config);
Application.Current.MainWindow?.Icon = WindowsManager.Instance.GetAppIcon(_config);
}
private async void menuExit_Click(object sender, RoutedEventArgs e) private async void menuExit_Click(object sender, RoutedEventArgs e)
{ {
tbNotify.Dispose(); tbNotify.Dispose();