Skip to content

Commit

Permalink
UI: Fixed crash when connection error occurs when checking for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SourMesen committed May 8, 2023
1 parent 4c603ca commit da0825a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion UI/ViewModels/MainMenuViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ private void InitHelpMenu(Window wnd)
public void CheckForUpdate(Window mainWindow, bool silent)
{
Task.Run(async () => {
UpdatePromptViewModel? updateInfo = await UpdatePromptViewModel.GetUpdateInformation();
UpdatePromptViewModel? updateInfo = await UpdatePromptViewModel.GetUpdateInformation(silent);
if(updateInfo == null) {
if(!silent) {
Dispatcher.UIThread.Post(() => {
Expand Down
8 changes: 6 additions & 2 deletions UI/ViewModels/UpdatePromptViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public UpdatePromptViewModel(UpdateInfo updateInfo)
_updateInfo = updateInfo;
}

public static async Task<UpdatePromptViewModel?> GetUpdateInformation()
public static async Task<UpdatePromptViewModel?> GetUpdateInformation(bool silent)
{
UpdateInfo? updateInfo = null;
try {
Expand All @@ -58,7 +58,11 @@ public UpdatePromptViewModel(UpdateInfo updateInfo)
}
}
} catch(Exception ex) {
await MesenMsgBox.ShowException(ex);
if(!silent) {
Dispatcher.UIThread.Post(() => {
MesenMsgBox.ShowException(ex);
});
}
}

return updateInfo != null ? new UpdatePromptViewModel(updateInfo) : null;
Expand Down

0 comments on commit da0825a

Please sign in to comment.