[nextgen/cardstack] resolve more issues with timeout

This commit is contained in:
bignutty 2025-02-22 18:07:57 +01:00
parent 0433c3a785
commit 99c9af9a5d

View file

@ -77,8 +77,7 @@ class DynamicCardStack {
* Kills the dynamic card stack.
*/
async kill(clearComponents) {
this.listener.clear();
if (clearComponents && !this.killed) await this._edit(this.getCurrentCard(), [])
if (clearComponents && !this.killed) await this._edit(this.getCurrentCard(), false, true);
this.killed = true;
@ -135,8 +134,7 @@ class DynamicCardStack {
})
if (createMessage) return this._edit({
...this.getCurrentCard(),
components: this.listener
...this.getCurrentCard()
});
return this;
@ -244,16 +242,21 @@ class DynamicCardStack {
* @param {Message} cardContent Card Content
* @param {boolean, Array} components Custom Components Array
*/
async _edit(cardContent, components = false) {
async _edit(cardContent, components = false, killComponents = false) {
let message = Object.assign({}, cardContent);
if (!components) {
this._renderComponents();
message.components = this.listener;
} else {
this._renderComponents(killComponents);
message.components = this.listener;
if (components) {
message.components = components;
}
// This should detatch the listener.
if(killComponents) {
message.components = this.listener.components;
}
if (message["_meta"]) delete message["_meta"];
try {
@ -425,9 +428,10 @@ class DynamicCardStack {
}
if (renderedSlots.length > 5) console.warn("Component Overflow - Limiting to 5.")
let compListener = this.listener;
compListener.components = renderedSlots.splice(0, 5)
return compListener;
this.listener.components = renderedSlots.splice(0, 5);
return this.listener;
}
/**