HomePhabricator
Diffusion Comm d6ad4b6bd74e

[desktop] Unregister did-fail-load event after startup

Description

[desktop] Unregister did-fail-load event after startup

Summary:
ENG-5606

We currently register an event listener for the did-fail-load event. It's used for app startup, which works like this:

  1. we display a window with some simple loader
  2. we create a hidden main window that tries to load web.comm.app
  3. If it fails and we get did-fail-load we try to load it again after 1s
  4. After we are succesful we get did-fisish-load event in which we call show() which displays the hidden window and puts it in front of other windows

The ENG-5606 issue happens when the auto-reload code fails because of network error. For some reason it triggers the did-fail-load event and we do steps (3) and (4). So after we regain network connection we call show() and Comm window steals focus from the user.

This diffs introduces a fix for that - we unregister the did-fail-load event handler after a succesfull web page load as it's only needed for startup.

Test Plan:
Wait for auto-update with network turned off. Without this diff the web app reloads (to a black screen as there is no internet), and after network connection is regained the window steals focused. After this diff the app neither reloads nor steals focus.
Additionaly the logs showed electron: Failed to load URL: https://verify.walletconnect.com/03f32dbe53350f23cffea2ddc28152ba with error: ERR_INTERNET_DISCONNECTED error so I tried if eth login worked, and I was able to display the QR code for eth login.

Reviewers: tomek, ashoat

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D9967

Details