Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GCal module's "time until event" text more frequently
While it's reasonable to have a refresh interval of several minutes between the GCal module hitting the server, the fact that the module (helpfully) displays the time until an event means that as times approach zero, they become relatively inaccurate - "3m" might show up next to a meeting that you were supposed to be in 2 minutes ago. (don't worry, that hasn't happened to me yet) This change introduces a goroutine to the GCal module that will update the module text using the most recently cached copy of events. By default, it runs every 30 seconds (this could be changed to 0 to make it opt-in if desired) or however many seconds is specified by the new config option `wtf.mods.gcal.textInterval`. To make sure the goroutine doesn't cause any synchronization issues if a text update were to trigger at the same time as a module refresh, this change also adds the use of `sync.Mutex` to gate setting GCal's text. Since both mutexes and having a goroutine within individual modules are not the sort of thing any other code in `wtf` does at this point in time, I'm definitely open to feedback on whether there might be better ways to do this. Additionally, the change in `wtf.go` fixes an issue I noticed when testing if my `Disable()` function worked - the main `Widgets` array wasn't being cleared out after disabling all widgets before re-creating new copies of them, so it still held pointers to the old ones.
- Loading branch information