Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): offer no message actions on an unsent placeholder
Yudhi Armyndharisd3f3f5184463
diff --git a/dashboard/src/components/chats/ChatThread.test.ts b/dashboard/src/components/chats/ChatThread.test.tsindex 2fbd5b7d9..dbff7612c 100644--- a/dashboard/src/components/chats/ChatThread.test.ts+++ b/dashboard/src/components/chats/ChatThread.test.ts@@ -55,7 +55,10 @@ const PROMPT: ChatMessageView = {metadata: { buttons: [{ id: 'y', text: 'Yes' }] },};-function renderThread(role: string): { clicks: string[]; container: HTMLElement } {+function renderThread(+ role: string,+ messages: ChatMessageView[] = [PROMPT],+): { clicks: string[]; container: HTMLElement } {window.localStorage.setItem('openwa_user_role', role);const clicks: string[] = [];const noop = () => {};@@ -66,7 +69,7 @@ function renderThread(role: string): { clicks: string[]; container: HTMLElementcreateElement(ChatThread, {sessionId: 's1',activeChat: CHAT,- messages: [PROMPT],+ messages,loadingMessages: false,messagesError: false,messagesContainerRef: createRef<HTMLDivElement>(),@@ -105,3 +108,15 @@ test('an operator key can tap a prompt choice and gets the message actions', asyawait rtl.waitFor(() => assert.deepEqual(clicks, ['y']));assert.ok(container.querySelector('.message-actions-menu'));});++test('an optimistic bubble with no WhatsApp id yet offers no reply, react or delete', () => {+ // Every action addresses the message by its WhatsApp id; a pending or failed placeholder only has+ // its local temp_ id, which the gateway can never resolve.+ for (const status of ['pending', 'failed'] as const) {+ const { container } = renderThread('operator', [+ { ...PROMPT, id: 'temp_1', waMessageId: undefined, direction: 'outgoing', status, metadata: undefined },+ ]);+ assert.ok(!container.querySelector('.message-actions-menu'), `a ${status} placeholder offered actions`);+ rtl.cleanup();+ }+});diff --git a/dashboard/src/components/chats/ChatThread.tsx b/dashboard/src/components/chats/ChatThread.tsxindex 5995cfa64..73eeb6db7 100644--- a/dashboard/src/components/chats/ChatThread.tsx+++ b/dashboard/src/components/chats/ChatThread.tsx@@ -495,8 +495,10 @@ function ChatThread({)}</div>- {/* Message actions menu (hover) */}- {canWrite && !isRevoked && (+ {/* Message actions menu (hover). Every action addresses the message by its WhatsApp+ id, so an optimistic bubble still on its local temp_ id (pending, or failed for+ good) offers none: the gateway could never resolve it. */}+ {canWrite && !isRevoked && Boolean(msg.waMessageId) && (<div className="message-actions-menu"><buttontype="button"