mirror of
https://github.com/2dust/v2rayN.git
synced 2026-10-15 01:35:00 +03:00
Add 'Check Only' update action
Introduce a new "Check Only" feature: add CheckOnlyCmd to CheckUpdateViewModel with CheckOnlyTask that queries updates (via UpdateService.CheckHasUpdateOnly) for selected cores and reports results without performing updates. Wire up a new btnCheckOnly in both Desktop and Avalonia views and bind the command. Add localized menuCheckOnly entries to multiple .resx files and update ResUI.Designer. Also shorten the pre-release label to "Check for pre-release" in resource files.
This commit is contained in:
@@ -9,6 +9,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||
|
||||
public IObservableCollection<CheckUpdateModel> CheckUpdateModels { get; } = new ObservableCollectionExtended<CheckUpdateModel>();
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> CheckOnlyCmd { get; }
|
||||
[Reactive] public bool EnableCheckPreReleaseUpdate { get; set; }
|
||||
|
||||
public CheckUpdateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
@@ -23,6 +24,13 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||
_ = UpdateView(_v2rayN, ex.Message);
|
||||
});
|
||||
|
||||
CheckOnlyCmd = ReactiveCommand.CreateFromTask(CheckOnly);
|
||||
CheckOnlyCmd.ThrownExceptions.Subscribe(ex =>
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
_ = UpdateView(_v2rayN, ex.Message);
|
||||
});
|
||||
|
||||
EnableCheckPreReleaseUpdate = _config.CheckUpdateItem.CheckPreReleaseUpdate;
|
||||
|
||||
this.WhenAnyValue(
|
||||
@@ -71,11 +79,54 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||
await ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
|
||||
private async Task CheckOnly()
|
||||
{
|
||||
await Task.Run(CheckOnlyTask);
|
||||
}
|
||||
|
||||
private async Task CheckUpdate()
|
||||
{
|
||||
await Task.Run(CheckUpdateTask);
|
||||
}
|
||||
|
||||
private async Task CheckOnlyTask()
|
||||
{
|
||||
await SaveSelectedCoreTypes();
|
||||
|
||||
for (var k = CheckUpdateModels.Count - 1; k >= 0; k--)
|
||||
{
|
||||
var item = CheckUpdateModels[k];
|
||||
if (item.IsSelected != true)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
await UpdateView(item.CoreType, "...");
|
||||
if (item.CoreType == _geo)
|
||||
{
|
||||
await UpdateView(item.CoreType, ResUI.menuCheckOnly + " (Not Support)");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse<ECoreType>(item.CoreType, out var type))
|
||||
{
|
||||
await UpdateView(item.CoreType, "Not Support");
|
||||
continue;
|
||||
}
|
||||
|
||||
var updateService = new UpdateService(_config, async (success, msg) => await Task.CompletedTask);
|
||||
var result = await updateService.CheckHasUpdateOnly(type, EnableCheckPreReleaseUpdate);
|
||||
if (result.Success && result.Version != null)
|
||||
{
|
||||
await UpdateView(item.CoreType, string.Format(ResUI.MsgCheckUpdateHasNewVersion, type, result.Version));
|
||||
}
|
||||
else
|
||||
{
|
||||
await UpdateView(item.CoreType, result.Msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CheckUpdateTask()
|
||||
{
|
||||
_lstUpdated.Clear();
|
||||
|
||||
Reference in New Issue
Block a user