fix(inventory): address code review findings
Some checks failed
Deploy to Production / test (push) Failing after 31s

- Replace setTimeout race in use-item flow with explicit Back button
- Fix collector end handler to re-render current view instead of blanking
- Add appendUseBackButton helper to attach navigation to use results
- Remove unused isInventoryInteraction import
- Fix rarity test type assertions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
syntaxbullet
2026-03-28 17:49:12 +01:00
parent 6a1498813f
commit 5188d86d61
3 changed files with 82 additions and 31 deletions

View File

@@ -289,6 +289,34 @@ export function getDiscardConfirmMessage(entry: InventoryEntry, viewerId: string
};
}
/**
* Wraps a use-item result message with a Back button so the user
* can return to the inventory after seeing the effect result.
*/
export function appendUseBackButton(message: any, viewerId: string): any {
const backRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId(`inv_use_back_${viewerId}`)
.setLabel("◀ Back to Inventory")
.setStyle(ButtonStyle.Primary)
);
// If CV2 message with components array, append to the first container
if (message.components && message.flags === MessageFlags.IsComponentsV2) {
const container = message.components[0];
if (container?.addActionRowComponents) {
container.addActionRowComponents(backRow);
}
return message;
}
// Embed-based fallback — add as a regular component row
return {
...message,
components: [...(message.components || []), backRow],
};
}
/**
* Resolves an item URL (icon or image) for use in CV2 components.
* Handles both local assets and remote URLs.