-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
TypingBubble.tsx
41 lines (32 loc) · 1.31 KB
/
TypingBubble.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2019-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
import { TypingBubble } from '../../components/conversation/TypingBubble';
import { strictAssert } from '../../util/assert';
import type { StateType } from '../reducer';
import { getIntl, getTheme } from '../selectors/user';
import { getConversationSelector } from '../selectors/conversations';
import { getPreferredBadgeSelector } from '../selectors/badges';
type ExternalProps = {
id: string;
};
const mapStateToProps = (state: StateType, props: ExternalProps) => {
const { id } = props;
const conversation = getConversationSelector(state)(id);
if (!conversation) {
throw new Error(`Did not find conversation ${id} in state!`);
}
const { typingContact } = conversation;
strictAssert(typingContact, 'Missing typingContact');
return {
...typingContact,
// This `|| []` is probably unnecessarily defensive. This should only affect v5.24.
badge: getPreferredBadgeSelector(state)(typingContact.badges || []),
conversationType: conversation.type,
i18n: getIntl(state),
theme: getTheme(state),
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartTypingBubble = smart(TypingBubble);