Skip to content

Added support for launching the application with a file on MacOS #478

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

Merged
merged 1 commit into from
Jan 10, 2021

Conversation

dlitty
Copy link

@dlitty dlitty commented Aug 31, 2020

Added support for launching the application with a file on MacOS by listening for the open-file and open-url events from the operating system, and forwarding them to the Electron.NET app when listeners are added

…istening for the open-file and open-url events from the operating system, and forwarding them to the Electron.NET app when listeners are added
dock = require('./api/dock')(socket);
dock = require('./api/dock')(socket);

socket.on('register-app-open-file-event', (id) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like the wrong place for this addition. There is no other targeted event handling of this nature in main.js. I would think that this belongs in api/app.ts or somewhere similar.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with that is timing. The electron.js docs explicitly state that those events must be done as early as possible in the startup - see https://www.electronjs.org/docs/api/app#event-open-file-macos. I had initially tried putting it into app.ts, but by the time it got there, the ready event had already fired, so it was too late.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about placing it in the app constructor. That looks like it fires before the calls here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately that does not work either. I tried moving it into the app constructor and it did not work. I also added some logging using electron-log to show the order of events:

[2020-10-11 11:39:05.673] [info] old location of will-finish-launching handler
[2020-10-11 11:39:06.805] [info] inside constructor
[2020-10-11 11:39:06.815] [info] old location of register handlers

The first line there is where I have the will-finish-launching handler being installed in the original PR. That is the key one - if you miss that event, the whole thing doesn't work. By the time it gets into the constructor, it is already too late.

@HaydnDias
Copy link

Is it possible to consider similar changes for windows/linux too? Would be extra useful for handling things like oidc callbacks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants