Skip to content

Commit

Permalink
toggle function
Browse files Browse the repository at this point in the history
  • Loading branch information
victornpb committed May 6, 2022
1 parent 2e3a75b commit d87c2d4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
11 changes: 8 additions & 3 deletions src/index-bd.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
// const { initUI, destroy } = require('./undiscord');
import { initUI, destroy, toggleWindow } from './undiscord';

export default class Undiscord {
// Required function. Called when the plugin is activated (including after reloads)
start() {
// initUI();
initUI();
}

getSettingsPanel() {
toggleWindow(true);
}

// Required function. Called when the plugin is deactivated
stop() {
// destroy();
destroy();
}
}
21 changes: 11 additions & 10 deletions src/undiscord.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ export function initUI() {
});
_observer.observe(discordElm, { attributes: false, childList: true, subtree: true });

function toggleWindow() {
if (undiscordWindow.style.display !== 'none') {
undiscordWindow.style.display = 'none';
undiscordBtn.style.color = 'var(--interactive-normal)';
}
else {
undiscordWindow.style.display = '';
undiscordBtn.style.color = 'var(--interactive-active)';
}
}

messagePicker.init();

Expand Down Expand Up @@ -128,6 +118,17 @@ export function initUI() {

}

export function toggleWindow(bool) {
if (bool || undiscordWindow.style.display === 'none') {
undiscordWindow.style.display = '';
undiscordBtn.style.color = 'var(--interactive-active)';
}
else {
undiscordWindow.style.display = 'none';
undiscordBtn.style.color = 'var(--interactive-normal)';
}
}

let _stopFlag;
const stopHndl = () => !(_stopFlag === true);

Expand Down

0 comments on commit d87c2d4

Please sign in to comment.