Skip to content
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: App bootup fails in browser due to missing isElectron checks #2168

Merged
merged 2 commits into from
Jun 25, 2020

Conversation

codebykat
Copy link
Member

Fix

Introduced in #2102. Right now loading in browser yields the following error: TypeError: window.electron is undefined

fyi @belcherj

@codebykat codebykat requested a review from a team June 25, 2020 03:26
@codebykat codebykat self-assigned this Jun 25, 2020
lib/app.tsx Outdated
'setAutoHideMenuBar',
this.props.settings.autoHideMenuBar
);
window.electron.send('settingsUpdate', this.props.settings);
Copy link
Member

Choose a reason for hiding this comment

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

also acceptable would be to use optional chaining, which I slightly prefer at the moment due to its brevity… (doesn't require isElectron)

window.electron?.receive('appCommand', this.onAppCommand);
window.electron?.send( 'setAutoHideMenuBar', this.props.settings.autoHideMenuBar );
window.electron?.send('settingsUpdate', this.props.settings);

the tradeoff could be argued as losing the context that this is intended to run only in Electron but I feel like that's obvious given the project and also given the naming

lib/app.tsx Outdated
@@ -178,7 +180,7 @@ export const App = connect(
componentDidUpdate(prevProps) {
const { settings } = this.props;

if (settings !== prevProps.settings) {
if (settings !== prevProps.settings && isElectron) {
Copy link
Member

Choose a reason for hiding this comment

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

same here… with optional chaining we don't need the additional check

Copy link
Member

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

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

Do as you see fit. I like the optional chaining but don't feel strongly about it.

@codebykat codebykat merged commit 0bcd034 into develop Jun 25, 2020
@codebykat codebykat deleted the fix/boot-error-when-not-in-electron branch June 25, 2020 04:01
@codebykat codebykat added this to the 1.20 milestone Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants