-
Notifications
You must be signed in to change notification settings - Fork 864
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
feat: update peer stats only when profile window is open #283
Conversation
Polling for the number of peers is now only updated when the user opens the profile window rather than having a timer constantly updating in the background. Got rid of `shouldPoll` because it seems unnecessary with the change in actually shown. Added a new event handler to trigger the polling when the window is how timers are set. The application also doesn't immediately run `pollStats` when loading the ipfs daemon.
i know there is a conflict here from the recent merges but should i bother fixing this? this pr has sat here for ~4 months without nary a comment. is it okay? does it need changes? i understand people are busy so i'm not pushing for an immediate merge. just want to know if i should spend time to fix the conflict. |
So sorry about the lack of feedback, let me review it now |
@@ -240,6 +231,8 @@ export function boot (lokker) { | |||
// Ensure single instance | |||
mb.app.makeSingleInstance(reboot) | |||
|
|||
mb.on('show', () => { pollStats(getIPFS()) }) |
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 should be once
to ensure it is only started once
const statsCache = {} | ||
|
||
function pollStats (ipfs) { | ||
const next = () => { | ||
setTimeout(() => { | ||
pollStats(ipfs) | ||
if (mb.window.isVisible()) { |
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.
please check for mb.window
I have seen it being undefined in edge cases
Looks pretty good to me, left some notes. If you could rebase & fix those I can merge it in |
hey so i tried running the latest master and was getting some errors. i tried reinstalling and now i just get a blue screen with a loading circle in the middle. are you seeing this as well? |
so i drilled down and found out that in this is what i see when i try to run
|
Try clearing (removing) your |
No, but I will. @diasdavid |
This was already integrated, see comment here #516 (comment). Thanks for the PR either way @swang :) |
The issue wasn't that polling didn't activate when you opened the window. The issue was that it continued to poll once you closed the window. You can look at the OP of this PR and the diff in the code and also look at the comments in #60. |
If you look at this line it will not poll if the window is closed. Yes, it will call the function again, but the API of IPFS never gets called. Unless you don't even want to call the polling function while the window is hidden. In that case, we could simply use events to start and stop polling. |
I guess I must have been confused then. I vaguely remember checking if it made the api calls beforehand to see if they fired after the window closed. |
Please let me know if my assumptions about things were correct (like shouldPoll being unnecessary if we're triggering from the 'show' event.)
Polling for the number of peers is now only updated when the user opens
the profile window rather than having a timer constantly updating in the
background.
Got rid of
shouldPoll
because it seems unnecessary with the change inactually shown.
Added a new event handler to trigger the polling when the window is
how timers are set. The application also doesn't immediately run
pollStats
when loading the ipfs daemon.Closes #60.