Files
Archive/shadowsocks-windows/shadowsocks-csharp/ViewModels/VersionUpdatePromptViewModel.cs
2024-12-31 19:31:59 +01:00

35 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json.Linq;
using ReactiveUI;
using Shadowsocks.Controller;
using System.Reactive;
namespace Shadowsocks.ViewModels
{
public class VersionUpdatePromptViewModel : ReactiveObject
{
public VersionUpdatePromptViewModel(JToken releaseObject)
{
_updateChecker = Program.MenuController.updateChecker;
_releaseObject = releaseObject;
ReleaseNotes = string.Concat(
$"# {((bool)_releaseObject["prerelease"] ? " Pre-release" : " Release")} {(string)_releaseObject["tag_name"] ?? "Failed to get tag name"}\r\n",
(string)_releaseObject["body"] ?? "Failed to get release notes");
Update = ReactiveCommand.CreateFromTask(_updateChecker.DoUpdate);
SkipVersion = ReactiveCommand.Create(_updateChecker.SkipUpdate);
NotNow = ReactiveCommand.Create(_updateChecker.CloseVersionUpdatePromptWindow);
}
private readonly UpdateChecker _updateChecker;
private readonly JToken _releaseObject;
public string ReleaseNotes { get; }
public ReactiveCommand<Unit, Unit> Update { get; }
public ReactiveCommand<Unit, Unit> SkipVersion { get; }
public ReactiveCommand<Unit, Unit> NotNow { get; }
}
}