signal-desktop/ts/components/conversation/TypingBubble.tsx

98 lines
2.3 KiB
TypeScript
Raw Normal View History

2021-05-07 22:21:10 +00:00
// Copyright 2018-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2018-11-14 19:10:32 +00:00
import React from 'react';
import classNames from 'classnames';
import { TypingAnimation } from './TypingAnimation';
import { Avatar } from '../Avatar';
import type { LocalizerType } from '../../types/Util';
import type { ConversationType } from '../../state/ducks/conversations';
2018-11-14 19:10:32 +00:00
2021-05-07 22:21:10 +00:00
export type Props = Pick<
ConversationType,
| 'acceptedMessageRequest'
| 'avatarPath'
| 'color'
| 'isMe'
| 'name'
| 'phoneNumber'
| 'profileName'
| 'sharedGroupNames'
| 'title'
> & {
conversationType: 'group' | 'direct';
2019-01-14 21:49:58 +00:00
i18n: LocalizerType;
};
2018-11-14 19:10:32 +00:00
export class TypingBubble extends React.PureComponent<Props> {
2020-09-14 19:51:27 +00:00
public renderAvatar(): JSX.Element | null {
2018-11-14 19:10:32 +00:00
const {
2021-05-07 22:21:10 +00:00
acceptedMessageRequest,
2018-11-14 19:10:32 +00:00
avatarPath,
color,
2021-05-07 22:21:10 +00:00
conversationType,
i18n,
isMe,
2018-11-14 19:10:32 +00:00
name,
phoneNumber,
profileName,
2021-05-07 22:21:10 +00:00
sharedGroupNames,
2020-07-24 01:35:32 +00:00
title,
2018-11-14 19:10:32 +00:00
} = this.props;
if (conversationType !== 'group') {
2020-09-14 19:51:27 +00:00
return null;
2018-11-14 19:10:32 +00:00
}
return (
2021-01-28 03:41:41 +00:00
<div className="module-message__author-avatar-container">
<Avatar
acceptedMessageRequest={acceptedMessageRequest}
avatarPath={avatarPath}
color={color}
conversationType="direct"
i18n={i18n}
isMe={isMe}
name={name}
phoneNumber={phoneNumber}
profileName={profileName}
title={title}
sharedGroupNames={sharedGroupNames}
size={28}
/>
2018-11-14 19:10:32 +00:00
</div>
);
}
2020-09-14 19:51:27 +00:00
public render(): JSX.Element {
2021-05-28 16:15:17 +00:00
const { i18n, conversationType } = this.props;
const isGroup = conversationType === 'group';
2018-11-14 19:10:32 +00:00
return (
<div
className={classNames(
'module-message',
'module-message--incoming',
isGroup ? 'module-message--group' : null
)}
>
2021-01-28 03:41:41 +00:00
{this.renderAvatar()}
<div className="module-message__container-outer">
<div
className={classNames(
'module-message__container',
2021-05-28 16:15:17 +00:00
'module-message__container--incoming'
2021-01-28 03:41:41 +00:00
)}
>
<div className="module-message__typing-container">
<TypingAnimation color="light" i18n={i18n} />
</div>
2018-11-14 19:10:32 +00:00
</div>
</div>
</div>
);
}
}