-
-
Notifications
You must be signed in to change notification settings - Fork 560
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
Handle initial network connectivity #775
Handle initial network connectivity #775
Conversation
1074c0c
to
aa02f27
Compare
I don’t think this is a correct way to approach connectivity problems.
We have to find a different way to force Messenger to re-establish its connections. |
@CvX I know it's not a great way to do it, but this PR only handles initial connectivity, before the user has a chance to interact with the app (for example, launching the app at login, when most of the time there's no internet connection and the app remains unresponsive/blank page). I'm not sure about item number 1, but 2 and 3 would definitely not apply here. |
Ah, my bad! 😶 In this case, you’re right, disregard 2 and 3. app.relaunch();
app.quit(); |
@CvX Alright, i've done exactly that. Thanks! |
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.
Alright, I've tried it out! 👨🔬
Other than the suggested minor changes, it would also be great if we used something like p-wait-for (with an interval of ~1000ms) so it isn't so hard on the CPU. 🙂 What do you think?
@CvX I've updated the PR and also used |
This results in a weird experience if you're actually offline. Then the app is just on the Dock without anything happening or showing. I think we need a timeout after 20 (?) seconds where it shows an error message to the user that they're offline, and with a "try again" button. |
2e9bb30
to
8081b03
Compare
8081b03
to
d38759a
Compare
I've tried the this PR on Windows, and a couple of times the relaunched app's window was blank. I didn't find out the root cause, but instead I decided to try a simpler solution: wait for the connection before creating the window. Let me know what you think @whitecrownclown, @sindresorhus. |
@CvX I think it's both simpler and better. No need to relaunch app/ reload window. I did notice that after this change triggering window 'activate' will throw an error so i added in a small check. |
source/util.ts
Outdated
@@ -33,3 +33,20 @@ export function showRestartDialog(message: string): void { | |||
} | |||
); | |||
} | |||
|
|||
export function showRetryDialog(message: string): void { |
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.
This is not really a generic utility (And the method name is outdated). I would move this and https://github.com/sindresorhus/caprine/pull/775/files#diff-21e9ddd93162651bd36f6e5bbfca8460R282 into a new file to contain the logic.
So in index.js
, it would just be:
(async () => {
await ensureOnline();
await app.whenReady();
...
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.
btw. these awaits don't have to be sequential, so we can change that to, e.g.:
await Promise.all([ensureOnline(), app.whenReady()]);
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.
@CvX There's not really any benefit in using Promise.all
here as app.whenReady()
doesn't do any work. It's just a shortcut for checking for the status of the app load. So the result of using Promise.all
is exactly the same as before. But it's fine, we can keep it.
@CvX Good solution! |
I've renamed |
@sindresorhus Prettier disagrees with you 😉 |
Good work everyone :) |
@sindresorhus ,
Hello!
This PR should fix the initial app launch issue with network connectivity and also allow for
Caprine
to be launched on system start/login without the need of a manual refresh. (Fixes #421)Any feedback is welcome. Thanks!