Skip to content

Commit

Permalink
Fix update manager not displaying self-update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgehog1029 committed Feb 23, 2023
1 parent 8dfb049 commit 6003069
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 6 additions & 3 deletions launcher/src/main/java/com/skcraft/launcher/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void run() {
}
});

updateManager.checkForUpdate();
updateManager.checkForUpdate(null);
}

/**
Expand Down Expand Up @@ -401,8 +401,11 @@ public URL propUrl(String key, String... args) {
/**
* Show the launcher.
*/
public void showLauncherWindow() {
mainWindowSupplier.get().setVisible(true);
public Window showLauncherWindow() {
Window window = mainWindowSupplier.get();
window.setVisible(true);

return window;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void tableChanged(TableModelEvent e) {
@Override
public void actionPerformed(ActionEvent e) {
loadInstances();
launcher.getUpdateManager().checkForUpdate();
launcher.getUpdateManager().checkForUpdate(LauncherFrame.this);
webView.browse(launcher.getNewsURL(), false);
}
});
Expand Down Expand Up @@ -394,8 +394,8 @@ public void gameStarted() {

@Override
public void gameClosed() {
launcher.showLauncherWindow();
launcher.getUpdateManager().checkForUpdate();
Window newLauncherWindow = launcher.showLauncherWindow();
launcher.getUpdateManager().checkForUpdate(newLauncherWindow);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public boolean getPendingUpdate() {
return pendingUpdate != null;
}

public void checkForUpdate() {
public void checkForUpdate(final Window window) {
ListenableFuture<LatestVersionInfo> future = launcher.getExecutor().submit(new UpdateChecker(launcher));

Futures.addCallback(future, new FutureCallback<LatestVersionInfo>() {
Expand All @@ -63,9 +63,11 @@ public void onSuccess(LatestVersionInfo result) {

@Override
public void onFailure(Throwable t) {

// Error handler attached below.
}
}, SwingExecutor.INSTANCE);

SwingHelper.addErrorDialogCallback(window, future);
}

public void performUpdate(final Window window) {
Expand Down

0 comments on commit 6003069

Please sign in to comment.