You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

VersionUpdatePromptViewModel.cs 1.3 kB

12345678910111213141516171819202122232425262728293031323334
  1. using Newtonsoft.Json.Linq;
  2. using ReactiveUI;
  3. using Shadowsocks.Controller;
  4. using System.Reactive;
  5. namespace Shadowsocks.ViewModels
  6. {
  7. public class VersionUpdatePromptViewModel : ReactiveObject
  8. {
  9. public VersionUpdatePromptViewModel(JToken releaseObject)
  10. {
  11. _updateChecker = Program.MenuController.updateChecker;
  12. _releaseObject = releaseObject;
  13. ReleaseNotes = string.Concat(
  14. $"# {((bool)_releaseObject["prerelease"] ? "⚠ Pre-release" : "ℹ Release")} {(string)_releaseObject["tag_name"] ?? "Failed to get tag name"}\r\n",
  15. (string)_releaseObject["body"] ?? "Failed to get release notes");
  16. Update = ReactiveCommand.CreateFromTask(_updateChecker.DoUpdate);
  17. SkipVersion = ReactiveCommand.Create(_updateChecker.SkipUpdate);
  18. NotNow = ReactiveCommand.Create(_updateChecker.CloseVersionUpdatePromptWindow);
  19. }
  20. private readonly UpdateChecker _updateChecker;
  21. private readonly JToken _releaseObject;
  22. public string ReleaseNotes { get; }
  23. public ReactiveCommand<Unit, Unit> Update { get; }
  24. public ReactiveCommand<Unit, Unit> SkipVersion { get; }
  25. public ReactiveCommand<Unit, Unit> NotNow { get; }
  26. }
  27. }