-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Don't 'handleProtocol' if mainWindow doesn't exist yet #1559
Conversation
@@ -433,7 +434,7 @@ ipcMain.on('Notify', (event, args) => { | |||
}) | |||
|
|||
ipcMain.on('frontendReady', () => { | |||
handleProtocol(mainWindow, process.argv) | |||
handleProtocol(mainWindow, [openUrlArgument, ...process.argv]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because of how handleProtocol works, this is fine, since it will go over all the elements of this array until if finds a heroic procotol, so if this is an empty string it's just skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
According to the Electron docs, we should add the This feels more like a band-aid fix to be honest |
Not sure, because we are not only depending on the front end, we are depending on the react app to be ready in the frontend, not just electron thinking the app is ready, I think the
I agree, the underlaying issue is a different one and this is a workaround on the wrong thing we are doing so at least it works, it fixes something for now but I agree that a refactor of how we launch games should be done at some point to not have to wait for the frontend |
The thing is that if we don't show anything on the frontend, in case the game doesn't run for some reason or we get some error, for instance, during save-sync or so on, the user will get no feedback and then will think that Heroic is broken. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the underlaying issue is a different one and this is a workaround on the wrong thing we are doing so at least it works, it fixes something for now but I agree that a refactor of how we launch games should be done at some point to not have to wait for the frontend
Yup, good to see we're on the same page then
Still, let's merge this for now
This fixes another issue I found on my jurney to add shortcuts on MacOS. On this pr #1501 I was testing opening heroic with arguments, but I didn't test opening heroic by letting the OS handle the
heroic://launch
url.When I tested that, I notices that the
open-url
event happens before the mainWindow object is even created, and it was trying tohandleProtocol
with no mainWindow object. Then theprocess.argv
variable was empty in the otherhandleProtocol
in thefrontendReady
callback becuase it was not passed as an argument to the process by the OS.In this PR I'm checking first if the mainWindow is exists, if it does it just calls
handleProtocol
, it if doesn't then it stores the url somewhere so it can be used in thefrontendReady
callback.This issue happened only when executing a protocol when heroic was closed.
Use the following Checklist if you have changed something on the Backend or Frontend: