Problem
After clicking Update Now in the update banner, there is a multi-second delay with no visual feedback before the Velopack installer prompt appears. The button remains enabled and the status text is unchanged, leaving the user with no indication that anything is happening.
Cause
ApplyUpdate_Click in MainWindow.xaml.cs performs a redundant CheckForUpdateAsync(force: true) network call before starting the download, instead of using the already-resolved _pendingUpdate held by the ViewModel:
// MainWindow.xaml.cs — ApplyUpdate_Click (current)
private async void ApplyUpdate_Click(object sender, RoutedEventArgs e)
{
if (_vm.HasUpdate is false) return;
var updateSvc = ((App)Application.Current).GetService<IUpdateService>();
if (updateSvc is null) return;
try
{
var info = await updateSvc.CheckForUpdateAsync(force: true); // ← redundant network round-trip
if (info is not null) await updateSvc.ApplyUpdateAsync(info);
}
...
}
MainViewModel already holds _pendingUpdate and has ApplyUpdateCommand wired to use it directly, but the button uses Click= instead of Command= binding.
Proposed Fix
MainViewModel.cs
- Add
_isApplyingUpdate backing field
- Add
IsApplyingUpdate property (setter notifies CanApplyUpdate and calls CommandManager.InvalidateRequerySuggested)
- Add
CanApplyUpdate computed property: _pendingUpdate is not null && !_isApplyingUpdate
- Update
ApplyUpdateCommand canExecute to () => CanApplyUpdate
- Update
ApplyUpdate() to set IsApplyingUpdate = true and UpdateText = "Downloading update…" before the async work; reset both on failure
- Update
NotifyUpdate() to also notify CanApplyUpdate
MainWindow.xaml
- Switch "Update Now" button from
Click="ApplyUpdate_Click" to Command="{Binding ApplyUpdateCommand}" with IsEnabled="{Binding CanApplyUpdate}"
MainWindow.xaml.cs
- Remove
ApplyUpdate_Click handler (logic moves fully into MainViewModel.ApplyUpdate())
Expected Behaviour
On click:
- Button disables immediately
UpdateText changes to "Downloading update…"
- Velopack installer prompt appears once download completes
- On failure: button re-enables,
UpdateText shows the error message
Problem
After clicking Update Now in the update banner, there is a multi-second delay with no visual feedback before the Velopack installer prompt appears. The button remains enabled and the status text is unchanged, leaving the user with no indication that anything is happening.
Cause
ApplyUpdate_ClickinMainWindow.xaml.csperforms a redundantCheckForUpdateAsync(force: true)network call before starting the download, instead of using the already-resolved_pendingUpdateheld by the ViewModel:MainViewModelalready holds_pendingUpdateand hasApplyUpdateCommandwired to use it directly, but the button usesClick=instead ofCommand=binding.Proposed Fix
MainViewModel.cs_isApplyingUpdatebacking fieldIsApplyingUpdateproperty (setter notifiesCanApplyUpdateand callsCommandManager.InvalidateRequerySuggested)CanApplyUpdatecomputed property:_pendingUpdate is not null && !_isApplyingUpdateApplyUpdateCommandcanExecute to() => CanApplyUpdateApplyUpdate()to setIsApplyingUpdate = trueandUpdateText = "Downloading update…"before the async work; reset both on failureNotifyUpdate()to also notifyCanApplyUpdateMainWindow.xamlClick="ApplyUpdate_Click"toCommand="{Binding ApplyUpdateCommand}"withIsEnabled="{Binding CanApplyUpdate}"MainWindow.xaml.csApplyUpdate_Clickhandler (logic moves fully intoMainViewModel.ApplyUpdate())Expected Behaviour
On click:
UpdateTextchanges to"Downloading update…"UpdateTextshows the error message