Skip to content

Commit

Permalink
perf: Clear data from memory when an action is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 9, 2024
1 parent a90ccdd commit d9a9454
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/com.gabe565.nightscout.sdPlugin/js/Nightscout.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,9 @@ class Nightscout {
clearTimeout(this.tickTimeout);
this.tickTimeout = null;
}

delete() {
this.stopTick();
delete nightscoutMap[this.context];
}
}
9 changes: 8 additions & 1 deletion src/com.gabe565.nightscout.sdPlugin/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ nightscoutAction.onDidReceiveSettings((data) =>

nightscoutAction.onKeyDown((data) => new Nightscout(data).beginTick());

nightscoutAction.onWillDisappear((data) => new Nightscout(data).stopTick());
nightscoutAction.onWillDisappear((data) => {
const ns = new Nightscout(data);
if (Object.keys(data.payload.settings).length === 0) {
ns.delete();
} else {
ns.stopTick();
}
});

nightscoutAction.onWillAppear((data) => new Nightscout(data).beginTick());

0 comments on commit d9a9454

Please sign in to comment.