mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-12 08:03:09 -04:00
[cardstack] fix interaction contexts, cleanup code, add comments/documentation
This commit is contained in:
parent
8c036e714a
commit
510cbbe60d
5 changed files with 273 additions and 118 deletions
|
@ -1,14 +1,14 @@
|
|||
const { anime, animeSupplemental} = require('#api');
|
||||
const { PERMISSION_GROUPS, OMNI_ANIME_FORMAT_TYPES, COLORS_HEX} = require('#constants');
|
||||
|
||||
const { createDynamicCardStack } = require("#cardstack");
|
||||
|
||||
const { hexToDecimalColor } = require("#utils/color");
|
||||
const { createEmbed, formatPaginationEmbeds, page } = require('#utils/embed');
|
||||
const { acknowledge } = require('#utils/interactions');
|
||||
const { smallPill, link, pill, stringwrapPreserveWords, timestamp, TIMESTAMP_FLAGS} = require('#utils/markdown');
|
||||
const { editOrReply } = require('#utils/message');
|
||||
|
||||
const { DynamicCardStack } = require("../../../labscore/cardstack/DynamicCardStack");
|
||||
const {STATIC_ASSETS} = require("#utils/statics");
|
||||
const { STATIC_ASSETS } = require("#utils/statics");
|
||||
|
||||
function renderAnimeResultsPage(context, res){
|
||||
let result = createEmbed("default", context, {
|
||||
|
@ -60,6 +60,8 @@ function renderAnimeResultsPage(context, res){
|
|||
}
|
||||
|
||||
return page(result, {}, {
|
||||
// Supplemental keys are provided by the backend,
|
||||
// allow for fetching extra data related to results.
|
||||
episodes_key: res.supplemental.episodes,
|
||||
characters_key: res.supplemental.characters,
|
||||
name: res.title,
|
||||
|
@ -101,13 +103,11 @@ module.exports = {
|
|||
|
||||
if(!pages.length) return editOrReply(context, createEmbed("warning", context, `No results found.`))
|
||||
|
||||
new DynamicCardStack(context, {
|
||||
createDynamicCardStack(context, {
|
||||
cards: formatPaginationEmbeds(pages),
|
||||
interactive: {
|
||||
episodes_button: {
|
||||
// Button Label
|
||||
label: "Episodes",
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
visible: true,
|
||||
condition: (page) => {
|
||||
|
@ -154,9 +154,7 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
characters_button: {
|
||||
// Button Label
|
||||
label: "Characters",
|
||||
// Next to pagination or new row
|
||||
inline: false,
|
||||
visible: true,
|
||||
condition: (page) => {
|
||||
|
@ -202,5 +200,5 @@ module.exports = {
|
|||
console.log(e)
|
||||
return editOrReply(context, createEmbed("error", context, `Unable to perform anime search.`))
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue