2021-11-15 20:01:58 +00:00
|
|
|
// Copyright 2019-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-05-31 22:42:01 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { mapDispatchToProps } from '../actions';
|
|
|
|
import { TypingBubble } from '../../components/conversation/TypingBubble';
|
2021-08-11 16:23:21 +00:00
|
|
|
import { strictAssert } from '../../util/assert';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2019-05-31 22:42:01 +00:00
|
|
|
|
2021-11-15 20:01:58 +00:00
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
2019-05-31 22:42:01 +00:00
|
|
|
import { getConversationSelector } from '../selectors/conversations';
|
2021-11-15 20:01:58 +00:00
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
2019-05-31 22:42:01 +00:00
|
|
|
|
|
|
|
type ExternalProps = {
|
|
|
|
id: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = (state: StateType, props: ExternalProps) => {
|
|
|
|
const { id } = props;
|
|
|
|
|
2021-11-15 20:01:58 +00:00
|
|
|
const conversationSelector = getConversationSelector(state);
|
|
|
|
const conversation = conversationSelector(id);
|
2019-05-31 22:42:01 +00:00
|
|
|
if (!conversation) {
|
|
|
|
throw new Error(`Did not find conversation ${id} in state!`);
|
|
|
|
}
|
|
|
|
|
2021-11-15 20:01:58 +00:00
|
|
|
strictAssert(conversation.typingContactId, 'Missing typing contact ID');
|
|
|
|
const typingContact = conversationSelector(conversation.typingContactId);
|
2021-08-11 16:23:21 +00:00
|
|
|
|
2019-05-31 22:42:01 +00:00
|
|
|
return {
|
2021-11-15 20:01:58 +00:00
|
|
|
...typingContact,
|
|
|
|
badge: getPreferredBadgeSelector(state)(typingContact.badges),
|
2019-05-31 22:42:01 +00:00
|
|
|
conversationType: conversation.type,
|
|
|
|
i18n: getIntl(state),
|
2021-11-15 20:01:58 +00:00
|
|
|
theme: getTheme(state),
|
2019-05-31 22:42:01 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartTypingBubble = smart(TypingBubble);
|