Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ function toast(msg, duration = 3500) {

// ── Main plugin ────────────────────────────────────────────────────────

// Set by mount() so unmount() can stop the auto-refresh timer, which
// otherwise keeps firing and re-rendering into a container the host has
// already handed to another plugin.
let activeStopAuto = null;

export function mount(container, api) {
let sessions = [];
let loading = false;
Expand Down Expand Up @@ -356,9 +361,11 @@ export function mount(container, api) {
render();
fetchSessions();
if (autoRefresh) startAuto();
activeStopAuto = stopAuto;
}

export function unmount(container) {
if (activeStopAuto) { activeStopAuto(); activeStopAuto = null; }
container.innerHTML = '';
const styles = document.getElementById('sm-styles');
if (styles) styles.remove();
Expand Down
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ function toast(msg, duration = 3500) {

// ── Main plugin ────────────────────────────────────────────────────────

// Set by mount() so unmount() can stop the auto-refresh timer, which
// otherwise keeps firing and re-rendering into a container the host has
// already handed to another plugin.
let activeStopAuto = null;

export function mount(container, api) {
let sessions = [];
let loading = false;
Expand Down Expand Up @@ -356,9 +361,11 @@ export function mount(container, api) {
render();
fetchSessions();
if (autoRefresh) startAuto();
activeStopAuto = stopAuto;
}

export function unmount(container) {
if (activeStopAuto) { activeStopAuto(); activeStopAuto = null; }
container.innerHTML = '';
const styles = document.getElementById('sm-styles');
if (styles) styles.remove();
Expand Down