-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updater functionality #644
Conversation
Codecov Report
@@ Coverage Diff @@
## main #644 +/- ##
==========================================
+ Coverage 63.92% 64.26% +0.34%
==========================================
Files 615 623 +8
Lines 17335 17646 +311
Branches 1102 1133 +31
==========================================
+ Hits 11082 11341 +259
- Misses 5976 6014 +38
- Partials 277 291 +14
Flags with carried forward coverage won't be shown. Click here to find out more. |
this.WhenAnyValue(view => view.ViewModel!.OldVersion) | ||
.Select(v => $"v{v}") | ||
.BindToUi(this, view => view.FromVersionTextBlock.Text) | ||
.DisposeWith(d); | ||
|
||
this.WhenAnyValue(view => view.ViewModel!.NewVersion) | ||
.Select(v => $"v{v}") | ||
.BindToUi(this, view => view.ToVersionTextBlock.Text) | ||
.DisposeWith(d); | ||
|
||
this.WhenAnyValue(view => view.ViewModel!.ShowSystemUpdateMessage) | ||
.Select(show => !show) | ||
.BindToUi(this, view => view.UpdateButton.IsEnabled) | ||
.DisposeWith(d); | ||
|
||
this.WhenAnyValue(view => view.ViewModel!.ShowSystemUpdateMessage) | ||
.BindToUi(this, view => view.UseSystemUpdater.IsVisible) | ||
.DisposeWith(d); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should use OneWayBind
instead of BindToUi
. That method also has an optional lambda argument to transform the inputs before they are passed to the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this binds on whatever thread fires the event in the VM, so it'll throw errors if anything modifies the VM but isn't on the UI thread.
this.WhenAnyValue(view => view.ViewModel!.ShowChangelog) | ||
.BindToUi(this, view => view.ChangelogButton.Command) | ||
.DisposeWith(d); | ||
|
||
this.WhenAnyValue(view => view.ViewModel!.UpdateCommand) | ||
.BindToUi(this, view => view.UpdateButton.Command) | ||
.DisposeWith(d); | ||
|
||
this.WhenAnyValue(view => view.ViewModel!.LaterCommand) | ||
.BindToUi(this, view => view.LaterButton.Command) | ||
.DisposeWith(d); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should use BindCommand
which automatically binds to the command of the given control:
this.BindCommand(ViewModel, vm => vm.LaterCommand, view => view.LaterButton).DisposeWith(d).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this binds on whatever thread fires the event in the VM, so it'll throw errors if anything modifies the VM but isn't on the UI thread.
{ | ||
|
||
if (CompileConstants.InstallationMethod == InstallationMethod.Manually || CompileConstants.IsDebug) | ||
return Version.Parse("0.0.0.1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this magic number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Low enough to trigger a update no matter what version we are on.
this.WhenAnyValue(vm => vm.Method) | ||
.Select(m => m is InstallationMethod.Archive or InstallationMethod.InnoSetup) | ||
.Select(c => !c) | ||
.BindToUi(this, view => view.ShowSystemUpdateMessage) | ||
.DisposeWith(d); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BindToUi
shouldn't be used in a VM. Subscribe
or Do
+ Subscribe
should be used instead:
SubscribeWithErrorLogging(value => ShowSystemUpdateMessage = view)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains the VM, DTOs and functionality for getting the releases from GitHub. This should probably be split up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that, but where would we put it? It's a single call and the only thing that uses those DTOs, and isn't even used in the tests. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They could probably go into the common library, which already contains the compile constants. The DTOs don't have to public and can be marked as internal.
Handling the feedback as part of #661 |
resolves #465
Adds the functionality described below. Shows the updater if an update is available and if the the metrics opt-in wasn't shown. This is to not spam the user with multiple overlays.