Skip to content
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

Merged
merged 10 commits into from
Sep 25, 2023
Merged

Updater functionality #644

merged 10 commits into from
Sep 25, 2023

Conversation

halgari
Copy link
Collaborator

@halgari halgari commented Sep 18, 2023

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.

updater

@halgari halgari requested a review from a team September 18, 2023 17:09
@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Merging #644 (42cab0e) into main (9d57ff1) will increase coverage by 0.34%.
Report is 7 commits behind head on main.
The diff coverage is 87.09%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
Linux 63.53% <86.29%> (+0.26%) ⬆️
Windows 63.47% <85.88%> (+0.39%) ⬆️
clean_environment_tests 64.25% <86.69%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage
...lays/MetricsOptIn/MetricsOptInDesignerViewModel.cs ø
src/NexusMods.Common/ApplicationConstants.cs 30.00%
....UI/Overlays/MetricsOptIn/MetricsOptInViewModel.cs 50.00%
...usMods.App.UI/Overlays/Updater/UpdaterViewModel.cs 79.41%
....App.UI/Overlays/Updater/UpdaterDesignViewModel.cs 91.89%
...pp.UI/Overlays/MetricsOptIn/MetricsOptInView.axaml 100.00%
...exusMods.App.UI/Overlays/Updater/UpdaterView.axaml 100.00%
...sMods.App.UI/Overlays/Updater/UpdaterView.axaml.cs 100.00%
...rc/NexusMods.App.UI/Resources/Language.Designer.cs 100.00%
src/NexusMods.App.UI/Services.cs 100.00%
... and 2 more
@erri120 erri120 added this to the v0.2 milestone Sep 19, 2023
Comment on lines +20 to +37
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);
Copy link
Member

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.

Copy link
Collaborator Author

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.

Comment on lines +39 to +49
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);
Copy link
Member

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).
Copy link
Collaborator Author

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");
Copy link
Member

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?

Copy link
Collaborator Author

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.

Comment on lines 41 to 45
this.WhenAnyValue(vm => vm.Method)
.Select(m => m is InstallationMethod.Archive or InstallationMethod.InnoSetup)
.Select(c => !c)
.BindToUi(this, view => view.ShowSystemUpdateMessage)
.DisposeWith(d);
Copy link
Member

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)
Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Member

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.

@halgari halgari merged commit a6ccf0d into main Sep 25, 2023
7 checks passed
@halgari
Copy link
Collaborator Author

halgari commented Sep 25, 2023

Handling the feedback as part of #661

@halgari halgari deleted the update-app branch September 25, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants