-
Notifications
You must be signed in to change notification settings - Fork 218
serverstatus@maksmokriev: fix BoxBgColor setting, fix multiple mainloop callbacks #1740
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,8 +39,8 @@ MyDesklet.prototype = { | |
| this.settings.bind("TextColorWARN", "TextColorWARN", this.onSettingsChanged.bind(this)); | ||
| this.settings.bind("TextColorERR", "TextColorERR", this.onSettingsChanged.bind(this)); | ||
| this.settings.bind("ContainerBgColor", "ContainerBgColor", this.onSettingsBgChanged.bind(this)); | ||
| this.settings.bind("BoxBgColor", "BoxBgColor", this.onSettingsBgChanged.bind(this)); | ||
| this.settings.bind("FontSize", "FontSize", this.onSettingsBgChanged.bind(this)); | ||
| this.settings.bind("BoxBgColor", "BoxBgColor", this.onSettingsChanged.bind(this)); | ||
| this.settings.bind("FontSize", "FontSize", this.onSettingsChanged.bind(this)); | ||
| this.settings.bind("ContainerFixedWidth", "ContainerFixedWidth", this.onSettingsBgChanged.bind(this)); | ||
| this.settings.bind("ContainerWidth", "ContainerWidth", this.onSettingsBgChanged.bind(this)); | ||
|
|
||
|
|
@@ -86,16 +86,23 @@ MyDesklet.prototype = { | |
|
|
||
| } else { | ||
| this.updateServersDisplay(); | ||
| //Delay the first updateStatus call by 10 seconds | ||
| Mainloop.timeout_add_seconds(5, () => { | ||
| this.updateStatus(); | ||
| //After the first call, we start a periodic update | ||
| this.mainloop = Mainloop.timeout_add_seconds(this.TimeRepeat, () => { | ||
|
|
||
| if (!this.mainloop || this.oldTimeRepeat != this.TimeRepeat) { | ||
| this.oldTimeRepeat = this.TimeRepeat; | ||
| //Delay the first updateStatus call by 5 seconds | ||
| Mainloop.timeout_add_seconds(5, () => { | ||
| this.updateStatus(); | ||
| return true; | ||
| if (this.mainloop) { | ||
| Mainloop.source_remove(this.mainloop); | ||
| } | ||
| //After the first call, we start a periodic update | ||
| this.mainloop = Mainloop.timeout_add_seconds(this.TimeRepeat, () => { | ||
| this.updateStatus(); | ||
| return true; | ||
| }); | ||
| return false; //Return false so that this timer only runs once | ||
| }); | ||
|
Comment on lines
+93
to
104
|
||
| return false; //Return false so that this timer only runs once | ||
| }); | ||
| } | ||
| } | ||
| }, | ||
|
|
||
|
|
||
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.
The variable
oldTimeRepeatis never initialized in the constructor, which means the first time this condition is evaluated, it will compareundefined != this.TimeRepeat, which will always be true. While this works for the first initialization, it would be clearer to explicitly initializethis.oldTimeRepeat = nullin the_initmethod to make the intent explicit.