diff --git a/__visual_tests__/workflow1.spec.ts b/__visual_tests__/workflow1.spec.ts index 84b49fca8..5b6c0b7d3 100644 --- a/__visual_tests__/workflow1.spec.ts +++ b/__visual_tests__/workflow1.spec.ts @@ -36,13 +36,13 @@ test('100', async ({ page, browserName }) => { await input.fill('trigger workflow1'); await assertScreenshot(page, `100-1.${browserName}`); await input.press('Enter'); - await page.waitForTimeout(500); + await page.waitForTimeout(1000); await assertScreenshot(page, `100-2.${browserName}`); // 2 let options = page.locator('.sendbird-suggested-replies__option'); await options.first().click(); - await page.waitForTimeout(500); + await page.waitForTimeout(1000); await assertScreenshot(page, `100-3.${browserName}`); // 3 @@ -60,18 +60,18 @@ test('100', async ({ page, browserName }) => { await chipContainer.locator(':scope > *').nth(5).click(); submitButton = page.locator('button.sendbird-button--primary'); await submitButton.click(); - await page.waitForTimeout(100); + await page.waitForTimeout(1000); await assertScreenshot(page, `100-5.${browserName}`); // 5 options = page.locator('.sendbird-suggested-replies__option'); await options.first().click(); - await page.waitForTimeout(100); + await page.waitForTimeout(1000); await assertScreenshot(page, `100-6.${browserName}`); // 6 options = page.locator('.sendbird-suggested-replies__option'); await options.nth(1).click(); - await page.waitForTimeout(100); + await page.waitForTimeout(1000); await assertScreenshot(page, `100-7.${browserName}`); }); diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-1-chromium-chromium-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-1-chromium-chromium-darwin.png deleted file mode 100644 index 00bf657d7..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-1-chromium-chromium-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-1-firefox-firefox-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-1-firefox-firefox-darwin.png deleted file mode 100644 index eec40fca1..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-1-firefox-firefox-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-2-chromium-chromium-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-2-chromium-chromium-darwin.png deleted file mode 100644 index 378b25220..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-2-chromium-chromium-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-2-firefox-firefox-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-2-firefox-firefox-darwin.png deleted file mode 100644 index bf93a8a47..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-2-firefox-firefox-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-3-chromium-chromium-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-3-chromium-chromium-darwin.png deleted file mode 100644 index 44bd75337..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-3-chromium-chromium-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-3-firefox-firefox-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-3-firefox-firefox-darwin.png deleted file mode 100644 index acf20ef72..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-3-firefox-firefox-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-4-chromium-chromium-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-4-chromium-chromium-darwin.png deleted file mode 100644 index 58731f2d6..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-4-chromium-chromium-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-4-firefox-firefox-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-4-firefox-firefox-darwin.png deleted file mode 100644 index 679fa9b0f..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-4-firefox-firefox-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-5-chromium-chromium-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-5-chromium-chromium-darwin.png deleted file mode 100644 index fb41addfc..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-5-chromium-chromium-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-5-firefox-firefox-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-5-firefox-firefox-darwin.png deleted file mode 100644 index 2c2a04554..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-5-firefox-firefox-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-6-chromium-chromium-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-6-chromium-chromium-darwin.png deleted file mode 100644 index 05c5144ef..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-6-chromium-chromium-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-6-firefox-firefox-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-6-firefox-firefox-darwin.png deleted file mode 100644 index 21047c540..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-6-firefox-firefox-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-7-chromium-chromium-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-7-chromium-chromium-darwin.png deleted file mode 100644 index 2372195ee..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-7-chromium-chromium-darwin.png and /dev/null differ diff --git a/__visual_tests__/workflow1.spec.ts-snapshots/100-7-firefox-firefox-darwin.png b/__visual_tests__/workflow1.spec.ts-snapshots/100-7-firefox-firefox-darwin.png deleted file mode 100644 index db3be7cdb..000000000 Binary files a/__visual_tests__/workflow1.spec.ts-snapshots/100-7-firefox-firefox-darwin.png and /dev/null differ diff --git a/src/components/chat/ui/ChatMessageList.tsx b/src/components/chat/ui/ChatMessageList.tsx index adbbe1893..afc03e7fe 100644 --- a/src/components/chat/ui/ChatMessageList.tsx +++ b/src/components/chat/ui/ChatMessageList.tsx @@ -20,7 +20,7 @@ import { useTypingTargetMessageId } from '../hooks/useTypingTargetMessageId'; export const ChatMessageList = () => { const { channel, dataSource, scrollSource, handlers } = useChatContext(); - const { botStudioEditProps, customUserAgentParam, stringSet, dateLocale } = useConstantState(); + const { botStudioEditProps, customUserAgentParam, stringSet, dateLocale, enableMessageGrouping } = useConstantState(); const typingTargetMessageId = useTypingTargetMessageId(); const { filteredMessages, shouldShowOriginalDate, renderBotStudioWelcomeMessages } = useBotStudioView(); @@ -54,7 +54,12 @@ export const ChatMessageList = () => { const lastMessageInChannel = filteredMessages[filteredMessages.length - 1]; const showRepliesOnLastMessage = message.messageId === lastMessageInChannel?.messageId; - const [top, bottom] = getMessageGrouping(message, filteredMessages[index - 1], filteredMessages[index + 1]); + const [top, bottom] = getMessageGrouping( + message, + enableMessageGrouping, + filteredMessages[index - 1], + filteredMessages[index + 1], + ); return (
diff --git a/src/const.ts b/src/const.ts index 25fb04dc8..6707af520 100644 --- a/src/const.ts +++ b/src/const.ts @@ -63,6 +63,7 @@ export const DEFAULT_CONSTANT = { enableMention: true, enableResetHistoryOnConnect: false, enableWidgetExpandButton: false, + enableMessageGrouping: true, dateLocale: enUS, enableHideWidgetForDeactivatedUser: false, messageInputControls: { @@ -311,6 +312,11 @@ interface ConstantFeatureFlags { * @description Enable widget expand button. * */ enableWidgetExpandButton: boolean; + /** + * @public + * @description Enable message grouping by timestamp. + * */ + enableMessageGrouping: boolean; } export interface CreateGroupChannelParams { diff --git a/src/context/ConstantContext.tsx b/src/context/ConstantContext.tsx index 046377e50..a3c2f68a1 100644 --- a/src/context/ConstantContext.tsx +++ b/src/context/ConstantContext.tsx @@ -91,6 +91,7 @@ export const ConstantStateProvider = (props: PropsWithChildren { if (!appId || !botId) { return null; } - + const host = getHost(region); return ( { } : undefined } + enableMessageGrouping={!disableTimestamps} /> ); }; diff --git a/src/utils/messages.ts b/src/utils/messages.ts index d51a213ee..388f508d6 100644 --- a/src/utils/messages.ts +++ b/src/utils/messages.ts @@ -3,7 +3,15 @@ import { isSameMinute } from 'date-fns'; import { messageExtension } from './messageExtension'; -export const getMessageGrouping = (curr: BaseMessage, prev?: BaseMessage, next?: BaseMessage): [boolean, boolean] => { +export const getMessageGrouping = ( + curr: BaseMessage, + enableMessageGrouping: boolean, + prev?: BaseMessage, + next?: BaseMessage, +): [boolean, boolean] => { + if (!enableMessageGrouping) { + return [true, true]; + } if (!curr.isUserMessage() && !curr.isFileMessage()) { return [false, false]; }