Skip to content

Commit

Permalink
fix: typing indicator styles
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Aug 29, 2024
1 parent 2332a70 commit a462e4a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/components/CustomMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ type Props = {

export default function CustomMessage(props: Props) {
const { message, activeSpinnerId, botUser } = props;
const { replacementTextList, enableEmojiFeedback, botStudioEditProps } = useConstantState();
const { replacementTextList, enableEmojiFeedback, botStudioEditProps = {} } = useConstantState();
const { userId: currentUserId } = useWidgetSession();
const { profileUrl } = botStudioEditProps?.botInfo ?? {};
const { botInfo } = botStudioEditProps;

const botUserId = botUser?.userId;
const botProfileUrl = profileUrl ?? botUser?.profileUrl ?? '';
const botProfileUrl = botInfo?.profileUrl ?? botUser?.profileUrl ?? '';
const isWaitingForBotReply = activeSpinnerId === message.messageId && !!botUser;

const shouldRenderFeedback = () => {
Expand Down Expand Up @@ -68,7 +68,7 @@ export default function CustomMessage(props: Props) {
return (
<div>
<CurrentUserMessage message={message} />
{isWaitingForBotReply && <CustomTypingIndicatorBubble botProfileUrl={botProfileUrl} />}
{isWaitingForBotReply && <CustomTypingIndicatorBubble />}
</div>
);
}
Expand Down
11 changes: 10 additions & 1 deletion src/components/CustomTypingIndicatorBubble.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import BotProfileImage from './BotProfileImage';
import { useChatContext } from './chat/context/ChatProvider';
import { useConstantState } from '../context/ConstantContext';
import { TypingBubble } from '../foundation/components/TypingBubble';

function CustomTypingIndicatorBubble({ botProfileUrl }: { botProfileUrl: string }) {
function CustomTypingIndicatorBubble() {
const { botStudioEditProps = {}, botId } = useConstantState();
const { channel } = useChatContext();

const botUser = channel?.members.find((member) => member.userId === botId);
const botInfo = botStudioEditProps.botInfo;
const botProfileUrl = botInfo?.profileUrl ?? botUser?.profileUrl;

return (
<div style={{ display: 'flex', alignItems: 'flex-end', gap: 8, marginTop: 16 }}>
<BotProfileImage size={28} profileUrl={botProfileUrl} />
Expand Down
2 changes: 1 addition & 1 deletion src/foundation/components/TypingBubble/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { css } from '@linaria/core';

export const typingDotContainer = css`
align-items: center;
border-radius: 16px;
border-radius: 100px;
display: flex;
gap: 6px;
justify-content: center;
Expand Down

0 comments on commit a462e4a

Please sign in to comment.