Skip to content

Commit

Permalink
feat: Exit the app if the game isn't running when you close the main …
Browse files Browse the repository at this point in the history
…window
  • Loading branch information
itssimple committed Aug 21, 2021
1 parent 26af8a8 commit dd00b6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ if (firstLaunch) {
}
}

window.eventEmitter.addEventListener("main-window-closed", function () {
overwolf.games.getRunningGameInfo(function (data) {
if (data == null) {
exitApp("No game running, no need to run in the background");
}
});
});

window.eventEmitter.addEventListener("game-exited", function (gameInfo) {
log("EVENT:GAME-EXITED", gameInfo);

Expand Down
1 change: 1 addition & 0 deletions src/scripts/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ async function logoutFromBungie() {
function bindExitButtonEvent(window) {
document.getElementById("exitButton").addEventListener("click", function () {
localStorage.removeItem("mainWindow_opened");
eventEmitter.emit("main-window-closed");
overwolf.windows.close(window.window.id, function () {});
});
}
Expand Down

0 comments on commit dd00b6f

Please sign in to comment.