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