mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 21:53:07 -04:00
[nextgen] fix memory leak, change default expiry to 5 minutes
This commit is contained in:
parent
01a10135d8
commit
fe8358ccf4
3 changed files with 12 additions and 12 deletions
|
@ -1,13 +1,14 @@
|
|||
const { createEmbed, page } = require("#utils/embed");
|
||||
const { iconAsEmojiObject } = require("#utils/markdown");
|
||||
const { editOrReply } = require("#utils/message");
|
||||
const { STATIC_ASSETS } = require("#utils/statics");
|
||||
|
||||
const { Context } = require("detritus-client/lib/command");
|
||||
const { MessageComponentTypes, InteractionCallbackTypes } = require("detritus-client/lib/constants");
|
||||
const { Message } = require("detritus-client/lib/structures");
|
||||
const { ComponentContext, Components, ComponentActionRow} = require("detritus-client/lib/utils");
|
||||
const {createEmbed, page} = require("#utils/embed");
|
||||
const {STATIC_ASSETS} = require("#utils/statics");
|
||||
|
||||
const activeStacks = new Map();
|
||||
const activeStacks = new WeakMap();
|
||||
|
||||
const DEFAULT_BUTTON_ICON_MAPPINGS = Object.freeze({
|
||||
"next": "button_chevron_right",
|
||||
|
@ -51,7 +52,7 @@ class DynamicCardStack {
|
|||
this.index = options.startingIndex || 0;
|
||||
this.rootIndex = this.index;
|
||||
this.loopPages = options.loop || true;
|
||||
this.expires = options.expires || 1*60*1000;
|
||||
this.expires = options.expires || 5*60*1000;
|
||||
|
||||
this.uniqueId = (Date.now()*Math.random()).toString(36);
|
||||
|
||||
|
@ -78,7 +79,7 @@ class DynamicCardStack {
|
|||
if(clearComponents) await this._edit(this.currentPage(), [])
|
||||
|
||||
// Remove reference to free the cardstack for GC
|
||||
activeStacks.delete(this.context.message?.id);
|
||||
activeStacks.delete(this.context.message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,12 +93,12 @@ class DynamicCardStack {
|
|||
|
||||
_createDynamicCardStack(){
|
||||
// Kill any previously active cardstacks
|
||||
if(activeStacks.get(this.context.message?.id)){
|
||||
if(activeStacks.get(this.context.message)){
|
||||
console.log(this.uniqueId + " is replacing " + this._getStackByMessageId(this.context.message?.id).uniqueId);
|
||||
this._getStackByMessageId(this.context.message?.id).kill();
|
||||
this._getStackByMessageId(this.context.message).kill();
|
||||
}
|
||||
|
||||
activeStacks.set(this.context.message?.id, this);
|
||||
activeStacks.set(this.context.message, this);
|
||||
}
|
||||
|
||||
_createTimeout(){
|
||||
|
@ -364,7 +365,6 @@ class DynamicCardStack {
|
|||
|
||||
console.log("new category is " + this.currentSelectedSubcategory)
|
||||
|
||||
// TODO: allow overriding index
|
||||
this.index = 0;
|
||||
|
||||
try{
|
||||
|
@ -413,4 +413,4 @@ class DynamicCardStack {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = DynamicCardStack
|
||||
module.exports.DynamicCardStack = DynamicCardStack;
|
Loading…
Add table
Add a link
Reference in a new issue