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

View File

@@ -71,16 +71,18 @@ public partial class StatusBarView
ViewModel.DispatcherRefreshIconInteraction.RegisterHandler(interaction =>
{
Application.Current?.Dispatcher.Invoke(async () =>
{
tbNotify.Icon = await WindowsManager.Instance.GetNotifyIcon(_config);
Application.Current.MainWindow?.Icon = WindowsManager.Instance.GetAppIcon(_config);
}, DispatcherPriority.Normal);
Application.Current?.Dispatcher.Invoke(async () => await RefreshIcon(), DispatcherPriority.Normal);
interaction.SetOutput(Unit.Default);
}).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)
{
tbNotify.Dispose();