diff --git a/extension.js b/extension.js index b14a604..2f320d0 100644 --- a/extension.js +++ b/extension.js @@ -212,10 +212,13 @@ export default class ICESpeedExtension extends Extension { /* * Only now do we create a repeating timer. */ - this._timerId = GLib.timeout_add_seconds( + this._timerId = GLib.timeout_add( GLib.PRIORITY_DEFAULT, - UPDATE_INTERVAL_SECONDS, + UPDATE_INTERVAL_SECONDS * 1000, () => { + if (!this._onIceWifi) + return GLib.SOURCE_REMOVE; + this._updateSpeed(); return GLib.SOURCE_CONTINUE; } @@ -240,16 +243,19 @@ export default class ICESpeedExtension extends Extension { /* * Cancel an in-progress curl invocation. */ - if (this._requestCancellable !== null) - this._requestCancellable.cancel(); - - if (this._requestProcess !== null) - this._requestProcess.force_exit(); + const cancellable = this._requestCancellable; + const process = this._requestProcess; this._requestCancellable = null; this._requestProcess = null; this._requestRunning = false; + if (cancellable !== null) + cancellable.cancel(); + + if (process !== null) + process.force_exit(); + /* * Completely disappear from panel. */