-
Notifications
You must be signed in to change notification settings - Fork 414
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
Refactor Electron's main process #951
Conversation
@alexliebowitz I think a decent portion of this code was originally yours, it'd be good to get your eyes on this changeset. |
I agree, everything looks good here to me but it would be gret to get Alex's take. I am ready to merge if Alex gives the thumbs up |
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.
Very minor things, can be merged now if needed. Awesome overall.
let URI; | ||
if (process.platform === 'win32' && String(argv[1]).startsWith('lbry')) { | ||
// Keep only command line / deep linked arguments | ||
URI = argv[1].replace(/\/$/, '').replace('/#', '#'); |
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.
Hmm, now we're doing this same substitution in two places instead of in one function. That feels brittle (what if we find another problem with Windows URI handling and don't realize it's there in two places), and also
We might want to move this back into its own function, or at least add another comment here. Just a thought.
} | ||
}); | ||
|
||
window.webContents.on('crashed', () => { |
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.
It doesn't seem like this event is actually sent on the renderer side. Did you mean to build that, or is it something we're going to add later?
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.
It's necessary to handle it: https://electronjs.org/docs/api/web-contents#event-crashed
import path from 'path'; | ||
import createWindow from './createWindow'; | ||
|
||
export default class Tray { |
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.
Does this need to be a whole object? create()
is only called once and it doesn't need any state, so maybe just a createTray
function that takes an updateAttachedWindow
callback?
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.
I went for a exported createTray()
function initially. However, since it also needs to manage the state of the window, I finally went for using a class.
This closes #938, closes #298 and fixes #298.