Skip to content

Commit

Permalink
feat: Add boolean parameter to control emoji attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
AhyoungRyu committed Sep 8, 2023
1 parent 5f69aeb commit 4d10fde
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const customConstants = {
},
replacementTextList: [['the Text extracts', 'ChatBot Knowledge Base']],
enableSourceMessage: false,
enableEmojiFeedback: true,
};

const App = () => {
Expand All @@ -203,6 +204,7 @@ const App = () => {
messageBottomContent={customConstants.messageBottomContent}
replacementTextList={customConstants.replacementTextList}
enableSourceMessage={customConstants.enableSourceMessage}
enableEmojiFeedback={customConstants.enableEmojiFeedback}
/>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const App = (props: Props) => {
customRefreshComponent={props.customRefreshComponent}
configureSession={props.configureSession}
enableSourceMessage={props.enableSourceMessage}
enableEmojiFeedback={props.enableEmojiFeedback}
/>
);
};
Expand Down
4 changes: 3 additions & 1 deletion src/components/BotMessageWithBodyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import styled from 'styled-components';

import { StartingPageAnimatorProps } from './CustomChannelComponent';
import { ReactionContainer } from './ReactionContainer';
import { useConstantState } from '../context/ConstantContext';
import botMessageImage from '../icons/bot-message-image.png';
import { formatCreatedAtToAMPM } from '../utils';

Expand Down Expand Up @@ -69,6 +70,7 @@ const EmptyImageContainer = styled.div`
`;

export default function BotMessageWithBodyInput(props: Props) {
const { enableEmojiFeedback } = useConstantState();
const {
botUser,
message,
Expand Down Expand Up @@ -109,7 +111,7 @@ export default function BotMessageWithBodyInput(props: Props) {
</Sender>
)}
{bodyComponent}
<ReactionContainer message={message} />
{enableEmojiFeedback && <ReactionContainer message={message} />}
</BodyContainer>
<SentTime>{formatCreatedAtToAMPM(message.createdAt)}</SentTime>
</Root>
Expand Down
12 changes: 9 additions & 3 deletions src/components/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ import SBConnectionStateProvider, {
import { assert, isMobile } from '../utils';

const SBComponent = () => {
const { applicationId, botId, userId, userNickName, configureSession } =
useConstantState();
const {
applicationId,
botId,
userId,
userNickName,
configureSession,
enableEmojiFeedback,
} = useConstantState();

assert(
applicationId !== null && botId !== null,
Expand Down Expand Up @@ -54,7 +60,7 @@ const SBComponent = () => {
configureSession={configureSession}
customExtensionParams={userAgentCustomParams.current}
breakPoint={isMobile}
isReactionEnabled={true}
isReactionEnabled={enableEmojiFeedback}
>
<>
<CustomChannel />
Expand Down
2 changes: 2 additions & 0 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const DEFAULT_CONSTANT: Constant = {
onClick: noop,
},
enableSourceMessage: true,
enableEmojiFeedback: true,
};

type ConfigureSession = (
Expand Down Expand Up @@ -139,6 +140,7 @@ export interface Constant {
customRefreshComponent: CustomRefreshComponent;
configureSession: ConfigureSession;
enableSourceMessage: boolean;
enableEmojiFeedback: boolean;
firstMessageData: FirstMessageItem[];
}

Expand Down
2 changes: 2 additions & 0 deletions src/context/ConstantContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const ConstantStateProvider = (props: ProviderProps) => {
configureSession: props.configureSession,
enableSourceMessage:
props.enableSourceMessage ?? initialState.enableSourceMessage,
enableEmojiFeedback:
props.enableEmojiFeedback ?? initialState.enableEmojiFeedback,
}),
[props]
);
Expand Down

0 comments on commit 4d10fde

Please sign in to comment.