fix(inventory): address code review findings
Some checks failed
Deploy to Production / test (push) Failing after 31s
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user