Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): reserve the box of an archived video before it loads
Yudhi Armyndharis4e206025b48f
diff --git a/dashboard/src/components/chats/ArchivedMediaPreview.test.ts b/dashboard/src/components/chats/ArchivedMediaPreview.test.tsindex 0298a1a55..34c8423e6 100644--- a/dashboard/src/components/chats/ArchivedMediaPreview.test.ts+++ b/dashboard/src/components/chats/ArchivedMediaPreview.test.ts@@ -221,9 +221,27 @@ test('an archived audio placeholder reserves the height of the player that replaassert.ok(placeholder, 'the placeholder did not render');assert.ok(placeholder.classList.contains('message-media-archived-loading-audio'));// The player has a fixed height, so a placeholder of that height means the bubble never grows when- // the bytes land (a reader scrolled up, or pinned to the bottom, would otherwise be moved by it).+ // the bytes land (a reader scrolled up, or pinned to the bottom, would otherwise be moved by it). The+ // player's bottom margin is 0.25rem larger than the placeholder's, which the box makes up.const css = readFileSync(new URL('../../pages/Chats.css', import.meta.url), 'utf8');- assert.match(css, /\.message-media-archived-loading-audio\s*\{[^}]*min-height:\s*54px/);+ assert.match(css, /\.message-media-archived-loading-audio\s*\{[^}]*min-height:\s*calc\(54px \+ 0\.25rem\)/);+});++test('an archived video placeholder reserves the box a video element has before its metadata loads', async () => {+ const { container } = rtl.render(+ createElement(ArchivedMediaPreview, {+ kind: 'video',+ fallback,+ load: () => new Promise<Blob>(() => undefined),+ }),+ );+ const placeholder = container.querySelector('.message-media-archived-loading');+ assert.ok(placeholder, 'the placeholder did not render');+ assert.ok(placeholder.classList.contains('message-media-archived-loading-video'));+ // A video element is 150px tall until it knows its size. An 18px placeholder swapped for it pushed the+ // text a reader was on down by 140px for every video above them.+ const css = readFileSync(new URL('../../pages/Chats.css', import.meta.url), 'utf8');+ assert.match(css, /\.message-media-archived-loading-video\s*\{[^}]*min-height:\s*calc\(150px \+ 0\.25rem\)/);});test('an archived audio player reports its arrival so a bottom-pinned thread stays pinned', async () => {diff --git a/dashboard/src/components/chats/ArchivedMediaPreview.tsx b/dashboard/src/components/chats/ArchivedMediaPreview.tsxindex 2dff9a701..4827f3a6c 100644--- a/dashboard/src/components/chats/ArchivedMediaPreview.tsx+++ b/dashboard/src/components/chats/ArchivedMediaPreview.tsx@@ -132,7 +132,9 @@ function ArchivedMediaPreview({return (<divref={anchorRef}- className={`message-media-omitted message-media-archived-loading${kind === 'audio' ? ' message-media-archived-loading-audio' : ''}`}+ className={`message-media-omitted message-media-archived-loading${+ kind === 'audio' || kind === 'video' ? ` message-media-archived-loading-${kind}` : ''+ }`}role="status"aria-busy="true"aria-label={t('common.loading')}diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex 89b79d19a..6b17c6a8b 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -1005,10 +1005,17 @@text-decoration: none;}-/* The archived audio placeholder holds the height of the native player that replaces it, so the bubble- does not grow when the bytes land and move a thread that was pinned to the bottom or being read. */+/* The archived audio and video placeholders hold the height of the element that replaces them, so the+ bubble does not grow when the bytes land and move a thread that was pinned to the bottom or being read.+ The element's own bottom margin is 0.5rem and the placeholder's 0.25rem, so the quarter rem that is+ missing from the margin is added to the box: a native audio player is 54px tall, and a video element+ that has no metadata yet has the default 150px replaced-element height. */.chats-page .message-media-archived-loading-audio {- min-height: 54px;+ min-height: calc(54px + 0.25rem);+}++.chats-page .message-media-archived-loading-video {+ min-height: calc(150px + 0.25rem);}/* The map preview keeps its own modest cap, but bounded by the bubble the way every other media type