Skip to content

Commit

Permalink
Deletes sourceMenu reference before adding to prevent errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sakithb committed Sep 6, 2021
1 parent 0ab0ad0 commit 291188b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const enable = () => {
settings = ExtensionUtils.getSettings();
loopFinished = true;
contentRemoved = true;

currentMetadata = null;
currentPlayer = null;
currentStatus = null;
Expand Down Expand Up @@ -432,6 +432,7 @@ const mainLoop = async () => {
currentMetadata = validPlayers.get(currentPlayer);

currentLabel = getDisplayLabel(currentMetadata);

addContent();
updateContent();
} else {
Expand Down Expand Up @@ -470,6 +471,7 @@ const startMainloop = () => {

const updateContent = () => {
log("[Media-Controls] Updating content");

let currentIcon = null;
for (playerIcon of playerIcons) {
if (currentPlayer.includes(playerIcon)) {
Expand Down Expand Up @@ -497,9 +499,9 @@ const updateContent = () => {
const addContent = () => {
if (contentRemoved) {
log("[Media-Controls] Adding content");
if (!Main.panel.statusArea["sourceMenu"]) {
Main.panel.addToStatusArea("sourceMenu", container, extensionIndex, extensionPosition);
}
// Deleting reference as safety measuremnt
delete Main.panel.statusArea["sourceMenu"];
Main.panel.addToStatusArea("sourceMenu", container, extensionIndex, extensionPosition);
for (element of elementOrder) {
if (element === "icon" && showPlayerIcon) {
box.add(buttonPlayer);
Expand All @@ -520,7 +522,6 @@ const addContent = () => {

box.add(buttonNext);
} else if (element === "menu" && showMenu) {
// As a safety measurement
box.add(menuIcon);
}
}
Expand Down

0 comments on commit 291188b

Please sign in to comment.