Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcho committed Oct 25, 2024
1 parent da28637 commit 997f9cf
Show file tree
Hide file tree
Showing 20 changed files with 30 additions and 9 deletions.
10 changes: 5 additions & 5 deletions __visual_tests__/workflow1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}`);
});
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 7 additions & 2 deletions src/components/chat/ui/ChatMessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 (
<div style={{ padding: '0 16px' }} key={getComponentKeyFromMessage(message)}>
Expand Down
6 changes: 6 additions & 0 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const DEFAULT_CONSTANT = {
enableMention: true,
enableResetHistoryOnConnect: false,
enableWidgetExpandButton: false,
enableMessageGrouping: true,
dateLocale: enUS,
enableHideWidgetForDeactivatedUser: false,
messageInputControls: {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/context/ConstantContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const ConstantStateProvider = (props: PropsWithChildren<ConstantContextPr
enableHideWidgetForDeactivatedUser:
props.enableHideWidgetForDeactivatedUser ?? initialState.enableHideWidgetForDeactivatedUser,
enableWidgetExpandButton: props.enableWidgetExpandButton ?? initialState.enableWidgetExpandButton,
enableMessageGrouping: props.enableMessageGrouping ?? initialState.enableMessageGrouping,
// ----- Legacy props ----- //
betaMark: props.betaMark ?? initialState.betaMark,
customBetaMarkText: props.customBetaMarkText ?? initialState.customBetaMarkText,
Expand Down
3 changes: 2 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const WidgetApp = () => {
if (!appId || !botId) {
return null;
}

const host = getHost(region);
return (
<App
Expand All @@ -45,6 +45,7 @@ const WidgetApp = () => {
}
: undefined
}
enableMessageGrouping={!disableTimestamps}
/>
);
};
Expand Down
10 changes: 9 additions & 1 deletion src/utils/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit 997f9cf

Please sign in to comment.