Using RxApp replace ViewAction
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System.Reactive.Disposables;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace v2rayN.Desktop.Views;
|
||||
@@ -24,25 +23,6 @@ public partial class CheckUpdateView : ReactiveUserControl<CheckUpdateViewModel>
|
||||
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case EViewAction.DispatcherCheckUpdate:
|
||||
if (obj is null)
|
||||
return false;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.UpdateViewResult((CheckUpdateModel)obj),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
|
||||
case EViewAction.DispatcherCheckUpdateFinished:
|
||||
if (obj is null)
|
||||
return false;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.UpdateFinishedResult((bool)obj),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Reactive.Disposables;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace v2rayN.Desktop.Views;
|
||||
@@ -31,17 +30,6 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
|
||||
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case EViewAction.DispatcherRefreshConnections:
|
||||
if (obj is null)
|
||||
return false;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.RefreshConnections((List<ConnectionItem>?)obj),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Reactive.Disposables;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using DynamicData;
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
@@ -40,23 +39,6 @@ public partial class ClashProxiesView : ReactiveUserControl<ClashProxiesViewMode
|
||||
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case EViewAction.DispatcherRefreshProxyGroups:
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.RefreshProxyGroups(),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
|
||||
case EViewAction.DispatcherProxiesDelayTest:
|
||||
if (obj is null)
|
||||
return false;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.ProxiesDelayTestResult((SpeedTestResult)obj),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ public partial class FullConfigTemplateWindow : WindowBase<FullConfigTemplateVie
|
||||
{
|
||||
ProcUtils.ProcessStart("https://github.com/2dust/v2rayN/wiki/Description-of-some-ui#%E5%AE%8C%E6%95%B4%E9%85%8D%E7%BD%AE%E6%A8%A1%E6%9D%BF%E8%AE%BE%E7%BD%AE");
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
btnCancel.Focus();
|
||||
|
||||
@@ -135,6 +135,7 @@ public partial class GlobalHotkeySettingWindow : WindowBase<GlobalHotkeySettingV
|
||||
|
||||
return res.ToString();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
btnCancel.Focus();
|
||||
|
||||
@@ -222,20 +222,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
|
||||
case EViewAction.DispatcherStatistics:
|
||||
if (obj is null)
|
||||
return false;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.SetStatisticsResult((ServerSpeedItem)obj),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
|
||||
case EViewAction.DispatcherReload:
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.ReloadResult(),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
|
||||
case EViewAction.Shutdown:
|
||||
if (obj != null && _blCloseByUser == false)
|
||||
{
|
||||
|
||||
@@ -211,6 +211,7 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
||||
ViewModel.destOverride = clbdestOverride.SelectedItems.Cast<string>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
btnCancel.Focus();
|
||||
|
||||
@@ -183,15 +183,6 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
||||
return false;
|
||||
return await new SubEditWindow((SubItem)obj).ShowDialog<bool>(_window);
|
||||
|
||||
case EViewAction.DispatcherSpeedTest:
|
||||
if (obj is null)
|
||||
return false;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.SetSpeedTestResult((SpeedTestResult)obj),
|
||||
DispatcherPriority.Default);
|
||||
|
||||
break;
|
||||
|
||||
case EViewAction.DispatcherRefreshServersBiz:
|
||||
Dispatcher.UIThread.Post(RefreshServersBiz, DispatcherPriority.Default);
|
||||
break;
|
||||
|
||||
@@ -135,6 +135,7 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
btnCancel.Focus();
|
||||
|
||||
@@ -56,15 +56,6 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case EViewAction.DispatcherServerAvailability:
|
||||
if (obj is null)
|
||||
return false;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.TestServerAvailabilityResult((string)obj),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
|
||||
|
||||
case EViewAction.DispatcherRefreshIcon:
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
|
||||
@@ -117,6 +117,7 @@ public partial class SubSettingWindow : WindowBase<SubSettingViewModel>
|
||||
menuClose_Click(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
lstSubscription.Focus();
|
||||
|
||||
Reference in New Issue
Block a user