[cardstack] add built-in buttons constant

This commit is contained in:
bignutty 2025-02-13 02:39:17 +01:00
parent 3e0078979c
commit 4ca49289c0

View file

@ -15,9 +15,14 @@ const {DISCORD_INVITES} = require("#constants");
*/
const activeStacks = new WeakMap();
const BUILT_IN_BUTTON_TYPES = Object.freeze({
NEXT_PAGE: "next",
PREVIOUS_PAGE: "previous"
})
const DEFAULT_BUTTON_ICON_MAPPINGS = Object.freeze({
"next": "button_chevron_right",
"previous": "button_chevron_left"
[BUILT_IN_BUTTON_TYPES.NEXT_PAGE]: "button_chevron_right",
[BUILT_IN_BUTTON_TYPES.PREVIOUS_PAGE]: "button_chevron_left"
});
const STACK_CACHE_KEYS = Object.freeze({
@ -397,8 +402,7 @@ class DynamicCardStack {
//this.lastInteraction = Date.now();
// Built-in Buttons
// TODO: derive this from a constant
if(["next","previous"].includes(ctx.data.customId)){
if(Object.values(BUILT_IN_BUTTON_TYPES).includes(ctx.data.customId)){
switch(ctx.data.customId){
case "next":
return ctx.respond({