Skip to content

Commit

Permalink
fixed welcome page 'k'-dialog (self log in) so you can exit again + f…
Browse files Browse the repository at this point in the history
…ixed java exiting error
  • Loading branch information
AquaJo committed Aug 21, 2024
1 parent e78b05c commit f14baba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
27 changes: 15 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ if (!gotTheLock) {
mainWindow.webContents.send('log', 'Update heruntergeladen!'); // ()

// delete java process if existent before quitAndInstall!! --> using jarExec.pid
deleteJavaProcess();
let obj = {};
obj.deleteJavaProcess = '1';
setCommunicatorJSON([obj, '']);
deleteJavaProcess(); // runs async bc java is responding to it in the background --> useful for setting communicator json at least to clean reset val
deleteJavaProcessSync(); // delete processes if existent immediately before quitAndInstall

autoUpdater.quitAndInstall();
});
Expand Down Expand Up @@ -135,19 +133,28 @@ if (!gotTheLock) {
if (!updating_finish) {
console.log('Exit with code: ' + code);
deleteJavaProcess();
deleteJavaProcessSync();
}
});
function deleteJavaProcess() {

function deleteJavaProcessSync() {
updating_finish = true; // general finish flag in theory
if (!jarExec) return;
try {
process.kill(jarExec.pid); // could have also used spawn process for jarExec ...
console.log(`Java process with PID ${jarExec.pid} terminated.`);
} catch (error) {
console.info(
console.log(
`Failed to terminate Java process with PID ${jarExec.pid}: ${error.message}. Maybe you were running an instance without java installed?`
);
}
}
function deleteJavaProcess() {
updating_finish = true; // general finish flag in theory
let obj = {};
obj.deleteJavaProcess = '1';
setCommunicatorJSON([obj, '']);
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
Expand All @@ -169,9 +176,7 @@ if (!gotTheLock) {
app.on('window-all-closed', async () => {
console.log('close detected');
// communicate with java to delete ongoing java program
let obj = {};
obj.deleteJavaProcess = '1';
setCommunicatorJSON([obj, '']);
deleteJavaProcess();

if (process.platform !== 'darwin') app.quit();
});
Expand Down Expand Up @@ -467,15 +472,13 @@ if (!gotTheLock) {
return;
}
mainWindow.webContents.send('noJavaAlert', ''); // also triggered on update due to process killing, but shouldn't matter
console.info(err);
console.log(err);
//throw err;
}
console.log(stdout);
console.log(stderr);
}
);
//console.log(jarExec);
console.log('jarExec.pid:' + jarExec.pid); // could have also used spawn process for jarExec ...
}
} else {
// TODO: No Java installed
Expand Down
8 changes: 5 additions & 3 deletions src/pages/welcomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ document.addEventListener('keydown', async (event) => {
callback: async function (data) {
if (!data) {
manualLoginOpen = false;
open();
//open(); // don't open it again if user cancels! (but keep the open of reopening ... )
} else {
let ip = data.IP;
if (ip !== undefined) {
Expand Down Expand Up @@ -221,15 +221,17 @@ document.addEventListener('keydown', async (event) => {
) //
.then(async (data) => {
try {
// bruh fr?
console.log(data[0].error);

manualLoginOpen = false;
open();

console.log('apiKey is incorrect');
} catch (error) {
console.log('successfull login');
// error should mean success ;) ...
// the typical "error is a success" ^^ ...
console.log('successfull login'); // ↓
// error should mean success ;) ... --> oh bruh I 'already' recognized / mentioned that back then ...
// clearing normal IP input
let input = document.getElementById('IPInput');
input.value = '';
Expand Down

0 comments on commit f14baba

Please sign in to comment.