iprodanovbg / homeassistant-desktop

🎛 Desktop application (Windows / macOS / Linux) for Home Assistant built with Electron
Apache License 2.0
394 stars 39 forks source link

Fix crash when reconnect is clicked #37

Open zehuanli opened 8 months ago

zehuanli commented 8 months ago

This PR fixes the issue that the app crashes when the "Reconnect" button is clicked. Related issues: #20 and #31

There are two underlying problems:

  1. Uncaught error in https://github.com/iprodanovbg/homeassistant-desktop/blob/ec49f76c2abf450de94cf5ced17358177a2f1649/app.js#L459 I simply made the error caught but didn't "fix" it, which seems fine.
  2. When the window is recreated through "Reconnect", the last window will be destroyed and thus https://github.com/iprodanovbg/homeassistant-desktop/blob/ec49f76c2abf450de94cf5ced17358177a2f1649/app.js#L757-L761 will be triggered and make the app silently quit. I disabled it. The "Quit" menu is not affected, and when clicked, the app should quit clean.

I only tested on Windows, so I'm not sure how this works on other platforms.