Fix network status after sleep - #154
Conversation
Fixed a bug causing layout issues after waking up from sleep
LeVraiArdox
left a comment
There was a problem hiding this comment.
Thanks for the fix, tho you might need to change some things. Keep in mind that we should avoid timers when we can.
Also, I think your update on the GitHub widget might be an error on your side.
There was a problem hiding this comment.
I thought you might ask that. It fixes a bug.
Once the system wakes up from sleep, the network is registered as not connected, even though it is, and the dashboard widgets use their "not connected" states
After fixing the issue of the system not correctly refreshing the network state, everything works as intended and the widgets switch to their correct connected view
However, because they were initially using the "not connected" state, once the "connected" state is applied, the layout is messed up.
This is specific to the GithubWidget since other widgets have unified states, while the github calendar uses different dimensions for each state (connected/disconnected)
This is what the widget looks like without touching this file:
Because its trying to fit the correct state while the stale disconnected state's different layout is in use
Idk how much of sense that explanation makes but yeah
| QTimer::singleShot(2000, this, [this]() { refreshAfterResume(); }); | ||
| QTimer::singleShot(5000, this, [this]() { refreshAfterResume(); }); |
There was a problem hiding this comment.
Firing updates at 0s, 2s, and 5s hoping NM catches up in time is a band-aid. On a slow system or heavily loaded Wi-Fi card, 5 seconds might still not be enough.
Instead of random timers on login1 wake up, listen to NM's state changes. NM gives state updates (NM_CLIENT_STATE_CHANGED or property notifications on NMClient / NMDevice). When system resumes, NM updates its client state to NM_STATE_CONNECTED_GLOBAL or NM_DEVICE_STATE_ACTIVATED automatically. hook into that signal to refresh once NM is actually ready.
There was a problem hiding this comment.
Ahh that sounds good
Will fix :)
Fix network status after sleep
This bug has existed for a while now. When the system wakes up after going to sleep, the network symbol in the bar shows that there is no network/network is disconnected - even though there is a network connection. The dashboard widgets also falsely believed this. This PR fixes that bug.
Before
After