mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-18 18:35:00 +03:00
Fix ViewModel and UI (#10093)
* Fix avalonia ScrollToEnd * Refactor ViewModel
This commit is contained in:
@@ -73,18 +73,16 @@ public class BulkObservableCollection<T> : ObservableCollection<T>
|
|||||||
|
|
||||||
public void ReplaceRange(IEnumerable<T>? collection)
|
public void ReplaceRange(IEnumerable<T>? collection)
|
||||||
{
|
{
|
||||||
if (collection == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_suppressNotification = true;
|
_suppressNotification = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Items.Clear();
|
Items.Clear();
|
||||||
foreach (var item in collection)
|
if (collection != null)
|
||||||
{
|
{
|
||||||
Items.Add(item);
|
foreach (var item in collection)
|
||||||
|
{
|
||||||
|
Items.Add(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ public class TaskManager
|
|||||||
_config = config;
|
_config = config;
|
||||||
_updateFunc = updateFunc;
|
_updateFunc = updateFunc;
|
||||||
|
|
||||||
Task.Run(ScheduledTasks);
|
_ = Task.Factory.StartNew(
|
||||||
|
ScheduledTasks,
|
||||||
|
CancellationToken.None,
|
||||||
|
TaskCreationOptions.LongRunning,
|
||||||
|
TaskScheduler.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ScheduledTasks()
|
private async Task ScheduledTasks()
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ public class StatisticsSingboxService
|
|||||||
_updateFunc = updateFunc;
|
_updateFunc = updateFunc;
|
||||||
_exitFlag = false;
|
_exitFlag = false;
|
||||||
|
|
||||||
_ = Task.Run(Run);
|
_ = Task.Factory.StartNew(
|
||||||
|
Run,
|
||||||
|
CancellationToken.None,
|
||||||
|
TaskCreationOptions.LongRunning,
|
||||||
|
TaskScheduler.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Init()
|
private async Task Init()
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ public class StatisticsXrayService
|
|||||||
_updateFunc = updateFunc;
|
_updateFunc = updateFunc;
|
||||||
_exitFlag = false;
|
_exitFlag = false;
|
||||||
|
|
||||||
_ = Task.Run(Run);
|
_ = Task.Factory.StartNew(
|
||||||
|
Run,
|
||||||
|
CancellationToken.None,
|
||||||
|
TaskCreationOptions.LongRunning,
|
||||||
|
TaskScheduler.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
|||||||
@@ -218,8 +218,7 @@ public partial class AddGroupServerViewModel : MyReactiveObject, ICloseable
|
|||||||
|
|
||||||
public async Task UpdatePreviewList()
|
public async Task UpdatePreviewList()
|
||||||
{
|
{
|
||||||
AllProfilePreviewItemsObs.Clear();
|
AllProfilePreviewItemsObs.ReplaceRange(await GroupProfileManager.GetChildProfileItemsByProtocolExtra(GetUpdatedProtocolExtra()));
|
||||||
AllProfilePreviewItemsObs.AddRange(await GroupProfileManager.GetChildProfileItemsByProtocolExtra(GetUpdatedProtocolExtra()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveServerAsync()
|
private async Task SaveServerAsync()
|
||||||
|
|||||||
@@ -36,14 +36,10 @@ public partial class CheckUpdateViewModel : MyReactiveObject
|
|||||||
EnableCheckPreReleaseUpdate = _config.CheckUpdateItem.CheckPreReleaseUpdate;
|
EnableCheckPreReleaseUpdate = _config.CheckUpdateItem.CheckPreReleaseUpdate;
|
||||||
EnableUpdateViaProxy = _config.CheckUpdateItem.UpdateViaProxy;
|
EnableUpdateViaProxy = _config.CheckUpdateItem.UpdateViaProxy;
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.EnableCheckPreReleaseUpdate)
|
||||||
x => x.EnableCheckPreReleaseUpdate,
|
.SubscribeAsync(async _ => await OnCheckPreReleaseUpdateChanged());
|
||||||
y => y == true)
|
|
||||||
.Subscribe(c => _ = OnCheckPreReleaseUpdateChanged());
|
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.EnableUpdateViaProxy)
|
||||||
x => x.EnableUpdateViaProxy,
|
|
||||||
y => y == true)
|
|
||||||
.Subscribe(c => _ = OnUpdateViaProxyChanged());
|
.Subscribe(c => _ = OnUpdateViaProxyChanged());
|
||||||
|
|
||||||
RefreshCheckUpdateItems();
|
RefreshCheckUpdateItems();
|
||||||
@@ -57,8 +53,7 @@ public partial class CheckUpdateViewModel : MyReactiveObject
|
|||||||
|
|
||||||
models.Add(GetGeoFileCheckUpdateModel());
|
models.Add(GetGeoFileCheckUpdateModel());
|
||||||
|
|
||||||
CheckUpdateModels.Clear();
|
CheckUpdateModels.ReplaceRange(models);
|
||||||
CheckUpdateModels.AddRange(models);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CheckUpdateModel GetCheckUpdateModel(ECoreType coreType)
|
private CheckUpdateModel GetCheckUpdateModel(ECoreType coreType)
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ public partial class ClashConnectionsViewModel : MyReactiveObject
|
|||||||
|
|
||||||
public async Task RefreshConnections(List<ConnectionItem>? connections)
|
public async Task RefreshConnections(List<ConnectionItem>? connections)
|
||||||
{
|
{
|
||||||
ConnectionItems.Clear();
|
|
||||||
|
|
||||||
var dtNow = DateTime.Now;
|
var dtNow = DateTime.Now;
|
||||||
var lstModel = new List<ClashConnectionModel>();
|
var lstModel = new List<ClashConnectionModel>();
|
||||||
foreach (var item in connections ?? [])
|
foreach (var item in connections ?? [])
|
||||||
@@ -85,12 +83,8 @@ public partial class ClashConnectionsViewModel : MyReactiveObject
|
|||||||
|
|
||||||
lstModel.Add(model);
|
lstModel.Add(model);
|
||||||
}
|
}
|
||||||
if (lstModel.Count <= 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConnectionItems.AddRange(lstModel);
|
ConnectionItems.ReplaceRange(lstModel);
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -257,19 +257,19 @@ public partial class MainWindowViewModel : MyReactiveObject
|
|||||||
AppEvents.AddServerViaClipboardRequested
|
AppEvents.AddServerViaClipboardRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async _ => await AddServerViaClipboardAsync(null));
|
.SubscribeAsync(async _ => await AddServerViaClipboardAsync(null));
|
||||||
|
|
||||||
AppEvents.HasUpdateNotified
|
AppEvents.HasUpdateNotified
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async bl => BlNewUpdate = bl);
|
.Subscribe(bl => BlNewUpdate = bl);
|
||||||
|
|
||||||
#endregion AppEvents
|
#endregion AppEvents
|
||||||
|
|
||||||
ProfilesViewModel.RefreshServersRequested
|
ProfilesViewModel.RefreshServersRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async _ => await RefreshServers());
|
.SubscribeAsync(async _ => await RefreshServers());
|
||||||
|
|
||||||
var vmReloadRequestedList = new List<IObservable<RxVoid>>
|
var vmReloadRequestedList = new List<IObservable<RxVoid>>
|
||||||
{
|
{
|
||||||
@@ -282,23 +282,23 @@ public partial class MainWindowViewModel : MyReactiveObject
|
|||||||
{
|
{
|
||||||
reloadRequested
|
reloadRequested
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async _ => await Reload());
|
.SubscribeAsync(async _ => await Reload());
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBarViewModel.AddServerViaScanRequested
|
StatusBarViewModel.AddServerViaScanRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async _ => await AddServerViaScanAsync());
|
.SubscribeAsync(async _ => await AddServerViaScanAsync());
|
||||||
|
|
||||||
StatusBarViewModel.AddServerViaClipboardRequested
|
StatusBarViewModel.AddServerViaClipboardRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async _ => await AddServerViaClipboardAsync(null));
|
.SubscribeAsync(async _ => await AddServerViaClipboardAsync(null));
|
||||||
|
|
||||||
StatusBarViewModel.ShowHideWindowRequested
|
StatusBarViewModel.ShowHideWindowRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async blShow =>
|
.SubscribeAsync(async blShow =>
|
||||||
{
|
{
|
||||||
await ShowHideWindowInteraction.HandleSafe(blShow);
|
await ShowHideWindowInteraction.HandleSafe(blShow);
|
||||||
});
|
});
|
||||||
@@ -306,12 +306,12 @@ public partial class MainWindowViewModel : MyReactiveObject
|
|||||||
StatusBarViewModel.SetDefaultServerRequested
|
StatusBarViewModel.SetDefaultServerRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async indexId => await ProfilesViewModel.SetDefaultServer(indexId));
|
.SubscribeAsync(async indexId => await ProfilesViewModel.SetDefaultServer(indexId));
|
||||||
|
|
||||||
StatusBarViewModel.SubscriptionsUpdateRequested
|
StatusBarViewModel.SubscriptionsUpdateRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async blProxy => await UpdateSubscriptionProcess("", blProxy));
|
.SubscribeAsync(async blProxy => await UpdateSubscriptionProcess("", blProxy));
|
||||||
|
|
||||||
_ = Init();
|
_ = Init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,18 +22,16 @@ public partial class MsgViewModel : MyReactiveObject
|
|||||||
AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true;
|
AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true;
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.MsgFilter)
|
x => x.MsgFilter)
|
||||||
.Subscribe(c => DoMsgFilter());
|
.Subscribe(c => DoMsgFilter());
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.AutoRefresh)
|
||||||
x => x.AutoRefresh,
|
.Subscribe(_ => _config.MsgUIItem.AutoRefresh = AutoRefresh);
|
||||||
y => y == true)
|
|
||||||
.Subscribe(c => _config.MsgUIItem.AutoRefresh = AutoRefresh);
|
|
||||||
|
|
||||||
AppEvents.SendMsgViewRequested
|
AppEvents.SendMsgViewRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
//.ObserveOn(RxSchedulers.MainThreadScheduler)
|
//.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(content => _ = AppendQueueMsg(content));
|
.Subscribe(content => _ = AppendQueueMsg(content));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FlushQueueMsg()
|
public void FlushQueueMsg()
|
||||||
@@ -74,9 +72,9 @@ public partial class MsgViewModel : MyReactiveObject
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await DispatcherShowMsgInteraction.HandleSafe(sb.ToString());
|
await DispatcherShowMsgInteraction.Handle(sb.ToString());
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch
|
||||||
{
|
{
|
||||||
_queueMsg.Enqueue(sb.ToString());
|
_queueMsg.Enqueue(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,24 +61,22 @@ public partial class ProfilesSelectViewModel : MyReactiveObject, ICloseable
|
|||||||
SelectFinish();
|
SelectFinish();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.SelectedSub)
|
||||||
x => x.SelectedSub,
|
.Where(y => y != null && !y.Remarks.IsNullOrEmpty() && _subIndexId != y.Id)
|
||||||
y => y != null && !y.Remarks.IsNullOrEmpty() && _subIndexId != y.Id)
|
.SubscribeAsync(async _ => await SubSelectedChangedAsync());
|
||||||
.Subscribe(async c => await SubSelectedChangedAsync(c));
|
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.ServerFilter)
|
||||||
x => x.ServerFilter,
|
.Where(y => y != null && _serverFilter != y)
|
||||||
y => y != null && _serverFilter != y)
|
.SubscribeAsync(async _ => await ServerFilterChanged());
|
||||||
.Subscribe(async c => await ServerFilterChanged(c));
|
|
||||||
|
|
||||||
// React to ConfigType filter changes
|
// React to ConfigType filter changes
|
||||||
this.WhenAnyValue(x => x.FilterExclude)
|
this.WhenAnyValue(x => x.FilterExclude)
|
||||||
.Skip(1)
|
.Skip(1)
|
||||||
.Subscribe(async _ => await RefreshServersBiz());
|
.SubscribeAsync(async _ => await RefreshServersBiz());
|
||||||
|
|
||||||
this.WhenAnyValue(x => x.FilterConfigTypes)
|
this.WhenAnyValue(x => x.FilterConfigTypes)
|
||||||
.Skip(1)
|
.Skip(1)
|
||||||
.Subscribe(async _ => await RefreshServersBiz());
|
.SubscribeAsync(async _ => await RefreshServersBiz());
|
||||||
|
|
||||||
#endregion WhenAnyValue && ReactiveCommand
|
#endregion WhenAnyValue && ReactiveCommand
|
||||||
|
|
||||||
@@ -128,12 +126,8 @@ public partial class ProfilesSelectViewModel : MyReactiveObject, ICloseable
|
|||||||
|
|
||||||
#region Servers && Groups
|
#region Servers && Groups
|
||||||
|
|
||||||
private async Task SubSelectedChangedAsync(bool c)
|
private async Task SubSelectedChangedAsync()
|
||||||
{
|
{
|
||||||
if (!c)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_subIndexId = SelectedSub?.Id;
|
_subIndexId = SelectedSub?.Id;
|
||||||
|
|
||||||
await RefreshServers();
|
await RefreshServers();
|
||||||
@@ -141,12 +135,8 @@ public partial class ProfilesSelectViewModel : MyReactiveObject, ICloseable
|
|||||||
await ProfilesFocusInteraction.HandleSafe(RxVoid.Default);
|
await ProfilesFocusInteraction.HandleSafe(RxVoid.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ServerFilterChanged(bool c)
|
private async Task ServerFilterChanged()
|
||||||
{
|
{
|
||||||
if (!c)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_serverFilter = ServerFilter;
|
_serverFilter = ServerFilter;
|
||||||
if (_serverFilter.IsNullOrEmpty())
|
if (_serverFilter.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
@@ -163,8 +153,7 @@ public partial class ProfilesSelectViewModel : MyReactiveObject, ICloseable
|
|||||||
{
|
{
|
||||||
var lstModel = await GetProfileItemsEx(_subIndexId, _serverFilter);
|
var lstModel = await GetProfileItemsEx(_subIndexId, _serverFilter);
|
||||||
|
|
||||||
ProfileItems.Clear();
|
ProfileItems.ReplaceRange(lstModel);
|
||||||
ProfileItems.AddRange(lstModel);
|
|
||||||
if (lstModel.Count > 0)
|
if (lstModel.Count > 0)
|
||||||
{
|
{
|
||||||
var selected = lstModel.FirstOrDefault(t => t.IndexId == _config.IndexId);
|
var selected = lstModel.FirstOrDefault(t => t.IndexId == _config.IndexId);
|
||||||
@@ -177,8 +166,7 @@ public partial class ProfilesSelectViewModel : MyReactiveObject, ICloseable
|
|||||||
var subItems = await AppManager.Instance.SubItems();
|
var subItems = await AppManager.Instance.SubItems();
|
||||||
subItems.Insert(0, new SubItem { Remarks = ResUI.AllGroupServers });
|
subItems.Insert(0, new SubItem { Remarks = ResUI.AllGroupServers });
|
||||||
|
|
||||||
SubItems.Clear();
|
SubItems.ReplaceRange(subItems);
|
||||||
SubItems.AddRange(subItems);
|
|
||||||
|
|
||||||
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
||||||
? subItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
? subItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
||||||
@@ -298,8 +286,7 @@ public partial class ProfilesSelectViewModel : MyReactiveObject, ICloseable
|
|||||||
: ProfileItems.OrderByDescending(KeySelector, comparer);
|
: ProfileItems.OrderByDescending(KeySelector, comparer);
|
||||||
|
|
||||||
var list = sorted.ToList();
|
var list = sorted.ToList();
|
||||||
ProfileItems.Clear();
|
ProfileItems.ReplaceRange(list);
|
||||||
ProfileItems.AddRange(list);
|
|
||||||
|
|
||||||
_dicHeaderSort[colName] = !asc;
|
_dicHeaderSort[colName] = !asc;
|
||||||
|
|
||||||
|
|||||||
@@ -103,19 +103,16 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
x => x.SelectedProfile,
|
x => x.SelectedProfile,
|
||||||
selectedSource => selectedSource != null && !selectedSource.IndexId.IsNullOrEmpty());
|
selectedSource => selectedSource != null && !selectedSource.IndexId.IsNullOrEmpty());
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.SelectedSub)
|
||||||
x => x.SelectedSub,
|
.Where(y => y != null && !y.Remarks.IsNullOrEmpty() && _config.SubIndexId != y.Id)
|
||||||
y => y != null && !y.Remarks.IsNullOrEmpty() && _config.SubIndexId != y.Id)
|
.SubscribeAsync(async _ => await SubSelectedChangedAsync());
|
||||||
.Subscribe(async c => await SubSelectedChangedAsync(c));
|
this.WhenAnyValue(x => x.SelectedMoveToGroup)
|
||||||
this.WhenAnyValue(
|
.Where(y => y != null && !y.Remarks.IsNullOrEmpty())
|
||||||
x => x.SelectedMoveToGroup,
|
.SubscribeAsync(async _ => await MoveToGroup());
|
||||||
y => y != null && !y.Remarks.IsNullOrEmpty())
|
|
||||||
.Subscribe(async c => await MoveToGroup(c));
|
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.ServerFilter)
|
||||||
x => x.ServerFilter,
|
.Where(y => y != null && _serverFilter != y)
|
||||||
y => y != null && _serverFilter != y)
|
.SubscribeAsync(async _ => await ServerFilterChanged());
|
||||||
.Subscribe(async c => await ServerFilterChanged(c));
|
|
||||||
|
|
||||||
//servers delete
|
//servers delete
|
||||||
EditServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
EditServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
@@ -249,7 +246,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
AppEvents.DispatcherStatisticsRequested
|
AppEvents.DispatcherStatisticsRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async result => await UpdateStatistics(result));
|
.SubscribeAsync(async result => await UpdateStatistics(result));
|
||||||
|
|
||||||
#endregion AppEvents
|
#endregion AppEvents
|
||||||
|
|
||||||
@@ -335,12 +332,8 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
|
|
||||||
#region Servers && Groups
|
#region Servers && Groups
|
||||||
|
|
||||||
private async Task SubSelectedChangedAsync(bool c)
|
private async Task SubSelectedChangedAsync()
|
||||||
{
|
{
|
||||||
if (!c)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_config.SubIndexId = SelectedSub?.Id;
|
_config.SubIndexId = SelectedSub?.Id;
|
||||||
|
|
||||||
await RefreshServers();
|
await RefreshServers();
|
||||||
@@ -348,12 +341,8 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
await ProfilesFocusInteraction.HandleSafe(RxVoid.Default);
|
await ProfilesFocusInteraction.HandleSafe(RxVoid.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ServerFilterChanged(bool c)
|
private async Task ServerFilterChanged()
|
||||||
{
|
{
|
||||||
if (!c)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_serverFilter = ServerFilter;
|
_serverFilter = ServerFilter;
|
||||||
if (_serverFilter.IsNullOrEmpty())
|
if (_serverFilter.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
@@ -375,8 +364,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
var lstModel = await GetProfileItemsEx(_config.SubIndexId, _serverFilter);
|
var lstModel = await GetProfileItemsEx(_config.SubIndexId, _serverFilter);
|
||||||
_lstProfile = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(lstModel)) ?? [];
|
_lstProfile = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(lstModel)) ?? [];
|
||||||
|
|
||||||
ProfileItems.Clear();
|
ProfileItems.ReplaceRange(lstModel ?? []);
|
||||||
ProfileItems.AddRange(lstModel ?? []);
|
|
||||||
if (lstModel?.Count > 0)
|
if (lstModel?.Count > 0)
|
||||||
{
|
{
|
||||||
ProfileItemModel? selected = null;
|
ProfileItemModel? selected = null;
|
||||||
@@ -397,8 +385,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
var subItems = await AppManager.Instance.SubItems();
|
var subItems = await AppManager.Instance.SubItems();
|
||||||
subItems.Insert(0, new SubItem { Remarks = ResUI.AllGroupServers });
|
subItems.Insert(0, new SubItem { Remarks = ResUI.AllGroupServers });
|
||||||
|
|
||||||
SubItems.Clear();
|
SubItems.ReplaceRange(subItems);
|
||||||
SubItems.AddRange(subItems);
|
|
||||||
|
|
||||||
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
||||||
? subItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
? subItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
||||||
@@ -672,13 +659,8 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
//move server
|
//move server
|
||||||
private async Task MoveToGroup(bool c)
|
private async Task MoveToGroup()
|
||||||
{
|
{
|
||||||
if (!c)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var lstSelected = await GetProfileItems(true);
|
var lstSelected = await GetProfileItems(true);
|
||||||
if (lstSelected == null)
|
if (lstSelected == null)
|
||||||
{
|
{
|
||||||
@@ -901,7 +883,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
if (await AppManager.Instance.WindowDialog.ShowDialogAsync(subEditViewModel) == true)
|
if (await AppManager.Instance.WindowDialog.ShowDialogAsync(subEditViewModel) == true)
|
||||||
{
|
{
|
||||||
await RefreshSubscriptions();
|
await RefreshSubscriptions();
|
||||||
await SubSelectedChangedAsync(true);
|
await SubSelectedChangedAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -920,7 +902,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
await ConfigHandler.DeleteSubItem(_config, item.Id);
|
await ConfigHandler.DeleteSubItem(_config, item.Id);
|
||||||
|
|
||||||
await RefreshSubscriptions();
|
await RefreshSubscriptions();
|
||||||
await SubSelectedChangedAsync(true);
|
await SubSelectedChangedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Subscription
|
#endregion Subscription
|
||||||
|
|||||||
@@ -100,8 +100,6 @@ public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable
|
|||||||
|
|
||||||
public void RefreshRulesItems()
|
public void RefreshRulesItems()
|
||||||
{
|
{
|
||||||
RulesItems.Clear();
|
|
||||||
|
|
||||||
var models = new List<RulesItemModel>();
|
var models = new List<RulesItemModel>();
|
||||||
foreach (var item in _rules)
|
foreach (var item in _rules)
|
||||||
{
|
{
|
||||||
@@ -120,7 +118,7 @@ public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable
|
|||||||
};
|
};
|
||||||
models.Add(it);
|
models.Add(it);
|
||||||
}
|
}
|
||||||
RulesItems.AddRange(models);
|
RulesItems.ReplaceRange(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RuleEditAsync(bool blNew)
|
public async Task RuleEditAsync(bool blNew)
|
||||||
|
|||||||
@@ -61,10 +61,10 @@ public partial class RoutingSettingViewModel : MyReactiveObject
|
|||||||
x => x.DomainStrategy4Singbox)
|
x => x.DomainStrategy4Singbox)
|
||||||
.Skip(1)
|
.Skip(1)
|
||||||
.DistinctUntilChanged()
|
.DistinctUntilChanged()
|
||||||
.Subscribe(x =>
|
.SubscribeAsync(async x =>
|
||||||
{
|
{
|
||||||
IsModified = true;
|
IsModified = true;
|
||||||
_ = SaveSettingsAsync();
|
await SaveSettingsAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,6 @@ public partial class RoutingSettingViewModel : MyReactiveObject
|
|||||||
|
|
||||||
public async Task RefreshRoutingItems()
|
public async Task RefreshRoutingItems()
|
||||||
{
|
{
|
||||||
RoutingItems.Clear();
|
|
||||||
var models = new List<RoutingItemModel>();
|
var models = new List<RoutingItemModel>();
|
||||||
|
|
||||||
var routings = await AppManager.Instance.RoutingItems();
|
var routings = await AppManager.Instance.RoutingItems();
|
||||||
@@ -102,7 +101,7 @@ public partial class RoutingSettingViewModel : MyReactiveObject
|
|||||||
};
|
};
|
||||||
models.Add(it);
|
models.Add(it);
|
||||||
}
|
}
|
||||||
RoutingItems.AddRange(models);
|
RoutingItems.ReplaceRange(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -123,26 +123,21 @@ public partial class StatusBarViewModel : MyReactiveObject
|
|||||||
|
|
||||||
#region WhenAnyValue && ReactiveCommand
|
#region WhenAnyValue && ReactiveCommand
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.SelectedRouting)
|
||||||
x => x.SelectedRouting,
|
.Where(y => y != null && !y.Remarks.IsNullOrEmpty())
|
||||||
y => y != null && !y.Remarks.IsNullOrEmpty())
|
.SubscribeAsync(async _ => await RoutingSelectedChangedAsync());
|
||||||
.Subscribe(async c => await RoutingSelectedChangedAsync(c));
|
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.SelectedServer)
|
||||||
x => x.SelectedServer,
|
.Where(y => y != null && !y.Text.IsNullOrEmpty())
|
||||||
y => y != null && !y.Text.IsNullOrEmpty())
|
.Subscribe(_ => ServerSelectedChanged());
|
||||||
.Subscribe(ServerSelectedChanged);
|
|
||||||
|
|
||||||
SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType;
|
SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType;
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.SystemProxySelected)
|
||||||
x => x.SystemProxySelected,
|
.Where(y => y >= 0)
|
||||||
y => y >= 0)
|
.SubscribeAsync(async _ => await DoSystemProxySelected());
|
||||||
.Subscribe(async c => await DoSystemProxySelected(c));
|
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.EnableTun)
|
||||||
x => x.EnableTun,
|
.SubscribeAsync(async _ => await DoEnableTun());
|
||||||
y => y == true)
|
|
||||||
.Subscribe(async c => await DoEnableTun(c));
|
|
||||||
|
|
||||||
CopyProxyCmdToClipboardCmd = ReactiveCommand.CreateFromTask(async () =>
|
CopyProxyCmdToClipboardCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
@@ -207,12 +202,12 @@ public partial class StatusBarViewModel : MyReactiveObject
|
|||||||
AppEvents.DispatcherStatisticsRequested
|
AppEvents.DispatcherStatisticsRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async result => await UpdateStatistics(result));
|
.SubscribeAsync(async result => await UpdateStatistics(result));
|
||||||
|
|
||||||
AppEvents.SysProxyChangeRequested
|
AppEvents.SysProxyChangeRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(async result => await SetListenerType(result));
|
.SubscribeAsync(async result => await SetListenerType(result));
|
||||||
|
|
||||||
#endregion AppEvents
|
#endregion AppEvents
|
||||||
|
|
||||||
@@ -300,19 +295,14 @@ public partial class StatusBarViewModel : MyReactiveObject
|
|||||||
var models = lstModel.Select(it => new ComboItem { ID = it.IndexId, Text = it.GetSummary() }).ToList();
|
var models = lstModel.Select(it => new ComboItem { ID = it.IndexId, Text = it.GetSummary() }).ToList();
|
||||||
|
|
||||||
BlServers = true;
|
BlServers = true;
|
||||||
Servers.Clear();
|
Servers.ReplaceRange(models);
|
||||||
Servers.AddRange(models);
|
|
||||||
|
|
||||||
// Update the ItemsSource before SelectedItem so a collection reset does not clear the tray selection.
|
// Update the ItemsSource before SelectedItem so a collection reset does not clear the tray selection.
|
||||||
SelectedServer = models.FirstOrDefault(it => it.ID == _config.IndexId) ?? new();
|
SelectedServer = models.FirstOrDefault(it => it.ID == _config.IndexId) ?? new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ServerSelectedChanged(bool c)
|
private void ServerSelectedChanged()
|
||||||
{
|
{
|
||||||
if (!c)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (SelectedServer == null)
|
if (SelectedServer == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -402,19 +392,13 @@ public partial class StatusBarViewModel : MyReactiveObject
|
|||||||
{
|
{
|
||||||
var routings = await AppManager.Instance.RoutingItems();
|
var routings = await AppManager.Instance.RoutingItems();
|
||||||
|
|
||||||
RoutingItems.Clear();
|
RoutingItems.ReplaceRange(routings);
|
||||||
RoutingItems.AddRange(routings);
|
|
||||||
|
|
||||||
SelectedRouting = routings.FirstOrDefault(t => t.IsActive == true);
|
SelectedRouting = routings.FirstOrDefault(t => t.IsActive == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RoutingSelectedChangedAsync(bool c)
|
private async Task RoutingSelectedChangedAsync()
|
||||||
{
|
{
|
||||||
if (!c)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SelectedRouting == null)
|
if (SelectedRouting == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -434,12 +418,8 @@ public partial class StatusBarViewModel : MyReactiveObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DoSystemProxySelected(bool c)
|
private async Task DoSystemProxySelected()
|
||||||
{
|
{
|
||||||
if (!c)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_config.SystemProxyItem.SysProxyType == (ESysProxyType)SystemProxySelected)
|
if (_config.SystemProxyItem.SysProxyType == (ESysProxyType)SystemProxySelected)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -447,7 +427,7 @@ public partial class StatusBarViewModel : MyReactiveObject
|
|||||||
await SetListenerType((ESysProxyType)SystemProxySelected);
|
await SetListenerType((ESysProxyType)SystemProxySelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DoEnableTun(bool c)
|
private async Task DoEnableTun()
|
||||||
{
|
{
|
||||||
if (_config.TunModeItem.EnableTun == EnableTun)
|
if (_config.TunModeItem.EnableTun == EnableTun)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ public partial class SubSettingViewModel : MyReactiveObject
|
|||||||
|
|
||||||
public async Task RefreshSubItems()
|
public async Task RefreshSubItems()
|
||||||
{
|
{
|
||||||
SubItems.Clear();
|
SubItems.ReplaceRange(await AppManager.Instance.SubItems());
|
||||||
SubItems.AddRange(await AppManager.Instance.SubItems());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task EditSubAsync(bool blNew)
|
public async Task EditSubAsync(bool blNew)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ global using ReactiveUI;
|
|||||||
global using ReactiveUI.Avalonia;
|
global using ReactiveUI.Avalonia;
|
||||||
global using ReactiveUI.Primitives;
|
global using ReactiveUI.Primitives;
|
||||||
global using ReactiveUI.Primitives.Disposables;
|
global using ReactiveUI.Primitives.Disposables;
|
||||||
|
global using ReactiveUI.Primitives.Extensions;
|
||||||
global using ReactiveUI.SourceGenerators;
|
global using ReactiveUI.SourceGenerators;
|
||||||
global using ServiceLib;
|
global using ServiceLib;
|
||||||
global using ServiceLib.Base;
|
global using ServiceLib.Base;
|
||||||
|
|||||||
@@ -35,39 +35,38 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
|||||||
CurrentLanguage = _config.UiItem.CurrentLanguage;
|
CurrentLanguage = _config.UiItem.CurrentLanguage;
|
||||||
|
|
||||||
this.WhenAnyValue(x => x.CurrentTheme)
|
this.WhenAnyValue(x => x.CurrentTheme)
|
||||||
.Subscribe(c =>
|
.Where(y => y.IsNotEmpty())
|
||||||
|
.SubscribeAsync(async _ =>
|
||||||
{
|
{
|
||||||
if (_config.UiItem.CurrentTheme != CurrentTheme)
|
if (_config.UiItem.CurrentTheme != CurrentTheme)
|
||||||
{
|
{
|
||||||
_config.UiItem.CurrentTheme = CurrentTheme;
|
_config.UiItem.CurrentTheme = CurrentTheme;
|
||||||
ModifyTheme();
|
ModifyTheme();
|
||||||
_ = ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.CurrentFontSize)
|
||||||
x => x.CurrentFontSize,
|
.Where(y => y > 0)
|
||||||
y => y > 0)
|
.SubscribeAsync(async _ =>
|
||||||
.Subscribe(c =>
|
|
||||||
{
|
{
|
||||||
if (_config.UiItem.CurrentFontSize != CurrentFontSize && CurrentFontSize >= Global.MinFontSize)
|
if (_config.UiItem.CurrentFontSize != CurrentFontSize && CurrentFontSize >= Global.MinFontSize)
|
||||||
{
|
{
|
||||||
_config.UiItem.CurrentFontSize = CurrentFontSize;
|
_config.UiItem.CurrentFontSize = CurrentFontSize;
|
||||||
ModifyFontSize();
|
ModifyFontSize();
|
||||||
_ = ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.CurrentLanguage)
|
||||||
x => x.CurrentLanguage,
|
.Where(y => !y.IsNullOrEmpty())
|
||||||
y => y != null && !y.IsNullOrEmpty())
|
.SubscribeAsync(async _ =>
|
||||||
.Subscribe(c =>
|
|
||||||
{
|
{
|
||||||
if (CurrentLanguage.IsNotEmpty() && _config.UiItem.CurrentLanguage != CurrentLanguage)
|
if (CurrentLanguage.IsNotEmpty() && _config.UiItem.CurrentLanguage != CurrentLanguage)
|
||||||
{
|
{
|
||||||
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
||||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||||
_ = ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips);
|
NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ public partial class MsgView : ReactiveUserControl<MsgViewModel>
|
|||||||
if (togScrollToEnd.IsChecked ?? true)
|
if (togScrollToEnd.IsChecked ?? true)
|
||||||
{
|
{
|
||||||
txtMsg.ScrollToEnd();
|
txtMsg.ScrollToEnd();
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
txtMsg.ScrollTo(txtMsg.LineCount, 0, AvaloniaEdit.Rendering.VisualYPosition.TextBottom, txtMsg.Bounds.Height, 0),
|
||||||
|
DispatcherPriority.Background);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ global using ReactiveUI;
|
|||||||
global using ReactiveUI.Builder;
|
global using ReactiveUI.Builder;
|
||||||
global using ReactiveUI.Primitives;
|
global using ReactiveUI.Primitives;
|
||||||
global using ReactiveUI.Primitives.Disposables;
|
global using ReactiveUI.Primitives.Disposables;
|
||||||
|
global using ReactiveUI.Primitives.Extensions;
|
||||||
global using ReactiveUI.SourceGenerators;
|
global using ReactiveUI.SourceGenerators;
|
||||||
global using ServiceLib;
|
global using ServiceLib;
|
||||||
global using ServiceLib.Base;
|
global using ServiceLib.Base;
|
||||||
|
|||||||
@@ -55,23 +55,21 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
|||||||
CurrentFontSize = _config.UiItem.CurrentFontSize;
|
CurrentFontSize = _config.UiItem.CurrentFontSize;
|
||||||
CurrentLanguage = _config.UiItem.CurrentLanguage;
|
CurrentLanguage = _config.UiItem.CurrentLanguage;
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.CurrentTheme)
|
||||||
x => x.CurrentTheme,
|
.Where(y => y != null && !y.IsNullOrEmpty())
|
||||||
y => y != null && !y.IsNullOrEmpty())
|
.SubscribeAsync(async _ =>
|
||||||
.Subscribe(c =>
|
|
||||||
{
|
{
|
||||||
if (_config.UiItem.CurrentTheme != CurrentTheme)
|
if (_config.UiItem.CurrentTheme != CurrentTheme)
|
||||||
{
|
{
|
||||||
_config.UiItem.CurrentTheme = CurrentTheme;
|
_config.UiItem.CurrentTheme = CurrentTheme;
|
||||||
ModifyTheme();
|
ModifyTheme();
|
||||||
_ = ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.SelectedSwatch)
|
||||||
x => x.SelectedSwatch,
|
.Where(y => y != null && !y.Name.IsNullOrEmpty())
|
||||||
y => y != null && !y.Name.IsNullOrEmpty())
|
.SubscribeAsync(async _ =>
|
||||||
.Subscribe(c =>
|
|
||||||
{
|
{
|
||||||
if (SelectedSwatch == null
|
if (SelectedSwatch == null
|
||||||
|| SelectedSwatch.Name.IsNullOrEmpty()
|
|| SelectedSwatch.Name.IsNullOrEmpty()
|
||||||
@@ -84,33 +82,31 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
|||||||
{
|
{
|
||||||
_config.UiItem.ColorPrimaryName = SelectedSwatch?.Name;
|
_config.UiItem.ColorPrimaryName = SelectedSwatch?.Name;
|
||||||
ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color);
|
ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color);
|
||||||
_ = ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.CurrentFontSize)
|
||||||
x => x.CurrentFontSize,
|
.Where(y => y > 0)
|
||||||
y => y > 0)
|
.SubscribeAsync(async _ =>
|
||||||
.Subscribe(c =>
|
|
||||||
{
|
{
|
||||||
if (_config.UiItem.CurrentFontSize != CurrentFontSize)
|
if (_config.UiItem.CurrentFontSize != CurrentFontSize)
|
||||||
{
|
{
|
||||||
_config.UiItem.CurrentFontSize = CurrentFontSize;
|
_config.UiItem.CurrentFontSize = CurrentFontSize;
|
||||||
ModifyFontSize();
|
ModifyFontSize();
|
||||||
_ = ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(x => x.CurrentLanguage)
|
||||||
x => x.CurrentLanguage,
|
.Where(y => y != null && !y.IsNullOrEmpty())
|
||||||
y => y != null && !y.IsNullOrEmpty())
|
.SubscribeAsync(async _ =>
|
||||||
.Subscribe(c =>
|
|
||||||
{
|
{
|
||||||
if (CurrentLanguage.IsNotEmpty() && _config.UiItem.CurrentLanguage != CurrentLanguage)
|
if (CurrentLanguage.IsNotEmpty() && _config.UiItem.CurrentLanguage != CurrentLanguage)
|
||||||
{
|
{
|
||||||
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
||||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||||
_ = ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips);
|
NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user