You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add per widget update intervals with possilbe configuration in deck files - #31
This is more or less the same that I already had impelmented in #22
I decided to place the interval right inside the WidgetConfig since this is a setting that can be applied to every widget.
I would have loved to model the interval as int but this would mean that widgets without a specified interval get the "default value" 0 which is not desireable.
Furthermore I'm not really happy with the setInterval call in every switch-case but I don't know how I could avoid this.
This is more or less the same that I already had impelmented in #22
Awesome, thanks for porting that over!
I decided to place the interval right inside the WidgetConfig since this is a setting that can be applied to every widget.
Sounds good.
I would have loved to model the interval as int but this would mean that widgets without a specified interval get the "default value" 0 which is not desireable.
I just simplified that logic a bit, so we can use a uint here. The default value zero now means the widget will only see an initial paint, with no further repaints. I've also managed to remove the need for a separate initialized bool, and implemented a specific RequiresUpdate method for the RecentWindowWidget.
Furthermore I'm not really happy with the setInterval call in every switch-case but I don't know how I could avoid this.
Instead of directly returning a newly generated Widget, we could store it a var first and then have one generic setInterval call outside the switch statement. This works because all widgets we create match the Widget interface, so they can be kept in the same type of variable.
Instead of manually setting a default interval, we could implement widget specific RequiresUpdate functions, that for cases where w.Interval is zero (the default) apply their own default interval. This keeps the logic inside the widget itself and widget.go becomes a bit less coupled to the individual widgets.
I just simplified that logic a bit, so we can use a uint here. The default value zero now means the widget will only see an initial paint, with no further repaints.
Not a huge of using zero as "no repaints required" but for the sake of cleaner code it is ok.
Instead of directly returning a newly generated Widget, we could store it a var first and then have one generic setInterval call outside the switch statement. This works because all widgets we create match the Widget interface, so they can be kept in the same type of variable.
Instead of manually setting a default interval, we could implement widget specific RequiresUpdate functions, that for cases where w.Interval is zero (the default) apply their own default interval. This keeps the logic inside the widget itself and widget.go becomes a bit less coupled to the individual widgets.
Like the way you moved the attribute unpacking to the widgets. This looks so much cleaner now!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Just a short heads up!
This is more or less the same that I already had impelmented in #22
I decided to place the
intervalright inside theWidgetConfigsince this is a setting that can be applied to every widget.I would have loved to model the
intervalasintbut this would mean that widgets without a specifiedintervalget the "default value" 0 which is not desireable.Furthermore I'm not really happy with the
setIntervalcall in every switch-case but I don't know how I could avoid this.