Skip to content

Commit

Permalink
remove mainloop sources
Browse files Browse the repository at this point in the history
  • Loading branch information
hslbck committed Nov 11, 2021
1 parent 366a7cb commit 60e2da8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion radio@hslbck.gmail.com/radioMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const _ = Gettext.gettext;
// timer for stream tag
const Interval = 10000; // 10 seconds
let timeoutId = 0;
let mediaKeysTimeoutId = null;
let oldTagLabel = '';

// Settings
Expand Down Expand Up @@ -699,12 +700,18 @@ function addToPanel() {
radioMenu = new RadioMenuButton();
Main.panel.addToStatusArea('radioMenu', radioMenu, 0, 'right');
radioMenu._enableSearchProvider();
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => radioMenu._enableMediaKeys());
mediaKeysTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => radioMenu._enableMediaKeys());
}

function removeFromPanel() {
radioMenu._stop();
radioMenu._disconnectMediaKeys();
radioMenu._disableSearchProvider();

if (mediaKeysTimeoutId) {
GLib.Source.remove(mediaKeysTimeoutId);
mediaKeysTimeoutId = null;
}

radioMenu.destroy();
}

0 comments on commit 60e2da8

Please sign in to comment.