Show badges in reaction viewer
This commit is contained in:
parent
2cbcd59609
commit
c63bf11a8f
14 changed files with 44 additions and 53 deletions
|
@ -97,7 +97,6 @@ const renderAudioAttachment: Props['renderAudioAttachment'] = props => (
|
||||||
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
||||||
attachments: overrideProps.attachments,
|
attachments: overrideProps.attachments,
|
||||||
author: overrideProps.author || getDefaultConversation(),
|
author: overrideProps.author || getDefaultConversation(),
|
||||||
authorBadge: overrideProps.authorBadge,
|
|
||||||
reducedMotion: boolean('reducedMotion', false),
|
reducedMotion: boolean('reducedMotion', false),
|
||||||
bodyRanges: overrideProps.bodyRanges,
|
bodyRanges: overrideProps.bodyRanges,
|
||||||
canReply: true,
|
canReply: true,
|
||||||
|
@ -128,6 +127,7 @@ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
||||||
expirationTimestamp:
|
expirationTimestamp:
|
||||||
number('expirationTimestamp', overrideProps.expirationTimestamp || 0) ||
|
number('expirationTimestamp', overrideProps.expirationTimestamp || 0) ||
|
||||||
undefined,
|
undefined,
|
||||||
|
getPreferredBadge: overrideProps.getPreferredBadge || (() => undefined),
|
||||||
i18n,
|
i18n,
|
||||||
id: text('id', overrideProps.id || ''),
|
id: text('id', overrideProps.id || ''),
|
||||||
renderingContext: 'storybook',
|
renderingContext: 'storybook',
|
||||||
|
@ -544,8 +544,8 @@ story.add('Avatar in Group', () => {
|
||||||
|
|
||||||
story.add('Badge in Group', () => {
|
story.add('Badge in Group', () => {
|
||||||
const props = createProps({
|
const props = createProps({
|
||||||
authorBadge: getFakeBadge(),
|
|
||||||
conversationType: 'group',
|
conversationType: 'group',
|
||||||
|
getPreferredBadge: () => getFakeBadge(),
|
||||||
status: 'sent',
|
status: 'sent',
|
||||||
text: 'Hello it is me, the saxophone.',
|
text: 'Hello it is me, the saxophone.',
|
||||||
});
|
});
|
||||||
|
|
|
@ -62,7 +62,7 @@ import type {
|
||||||
LocalizerType,
|
LocalizerType,
|
||||||
ThemeType,
|
ThemeType,
|
||||||
} from '../../types/Util';
|
} from '../../types/Util';
|
||||||
import type { BadgeType } from '../../badges/types';
|
import type { PreferredBadgeSelectorType } from '../../state/selectors/badges';
|
||||||
import type {
|
import type {
|
||||||
ContactNameColorType,
|
ContactNameColorType,
|
||||||
ConversationColorType,
|
ConversationColorType,
|
||||||
|
@ -157,7 +157,6 @@ export type PropsData = {
|
||||||
| 'title'
|
| 'title'
|
||||||
| 'unblurredAvatarPath'
|
| 'unblurredAvatarPath'
|
||||||
>;
|
>;
|
||||||
authorBadge: undefined | BadgeType;
|
|
||||||
reducedMotion?: boolean;
|
reducedMotion?: boolean;
|
||||||
conversationType: ConversationTypeType;
|
conversationType: ConversationTypeType;
|
||||||
attachments?: Array<AttachmentType>;
|
attachments?: Array<AttachmentType>;
|
||||||
|
@ -204,6 +203,7 @@ export type PropsData = {
|
||||||
export type PropsHousekeeping = {
|
export type PropsHousekeeping = {
|
||||||
containerElementRef: RefObject<HTMLElement>;
|
containerElementRef: RefObject<HTMLElement>;
|
||||||
containerWidthBreakpoint: WidthBreakpoint;
|
containerWidthBreakpoint: WidthBreakpoint;
|
||||||
|
getPreferredBadge: PreferredBadgeSelectorType;
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
interactionMode: InteractionModeType;
|
interactionMode: InteractionModeType;
|
||||||
theme: ThemeType;
|
theme: ThemeType;
|
||||||
|
@ -1191,7 +1191,8 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderAvatar(): JSX.Element | undefined {
|
public renderAvatar(): JSX.Element | undefined {
|
||||||
const { author, authorBadge, i18n, showContactModal, theme } = this.props;
|
const { author, getPreferredBadge, i18n, showContactModal, theme } =
|
||||||
|
this.props;
|
||||||
|
|
||||||
if (!this.hasAvatar()) {
|
if (!this.hasAvatar()) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -1207,7 +1208,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
<Avatar
|
<Avatar
|
||||||
acceptedMessageRequest={author.acceptedMessageRequest}
|
acceptedMessageRequest={author.acceptedMessageRequest}
|
||||||
avatarPath={author.avatarPath}
|
avatarPath={author.avatarPath}
|
||||||
badge={authorBadge}
|
badge={getPreferredBadge(author.badges)}
|
||||||
color={author.color}
|
color={author.color}
|
||||||
conversationType="direct"
|
conversationType="direct"
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
|
@ -1946,7 +1947,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
};
|
};
|
||||||
|
|
||||||
public renderReactions(outgoing: boolean): JSX.Element | null {
|
public renderReactions(outgoing: boolean): JSX.Element | null {
|
||||||
const { reactions = [], i18n } = this.props;
|
const { getPreferredBadge, reactions = [], i18n, theme } = this.props;
|
||||||
|
|
||||||
if (!this.hasReactions()) {
|
if (!this.hasReactions()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -2095,9 +2096,11 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
...style,
|
...style,
|
||||||
zIndex: 2,
|
zIndex: 2,
|
||||||
}}
|
}}
|
||||||
|
getPreferredBadge={getPreferredBadge}
|
||||||
reactions={reactions}
|
reactions={reactions}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
onClose={this.toggleReactionViewer}
|
onClose={this.toggleReactionViewer}
|
||||||
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Popper>
|
</Popper>
|
||||||
|
|
|
@ -27,7 +27,6 @@ const defaultMessage: MessageDataPropsType = {
|
||||||
id: 'some-id',
|
id: 'some-id',
|
||||||
title: 'Max',
|
title: 'Max',
|
||||||
}),
|
}),
|
||||||
authorBadge: getFakeBadge(),
|
|
||||||
canReply: true,
|
canReply: true,
|
||||||
canDeleteForEveryone: true,
|
canDeleteForEveryone: true,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
|
|
|
@ -64,7 +64,7 @@ export type PropsData = {
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
theme: ThemeType;
|
theme: ThemeType;
|
||||||
getPreferredBadge: PreferredBadgeSelectorType;
|
getPreferredBadge: PreferredBadgeSelectorType;
|
||||||
} & Pick<MessagePropsType, 'interactionMode'>;
|
} & Pick<MessagePropsType, 'getPreferredBadge' | 'interactionMode'>;
|
||||||
|
|
||||||
export type PropsBackboneActions = Pick<
|
export type PropsBackboneActions = Pick<
|
||||||
MessagePropsType,
|
MessagePropsType,
|
||||||
|
@ -276,6 +276,7 @@ export class MessageDetail extends React.Component<Props> {
|
||||||
contactNameColor,
|
contactNameColor,
|
||||||
displayTapToViewMessage,
|
displayTapToViewMessage,
|
||||||
doubleCheckMissingQuoteReference,
|
doubleCheckMissingQuoteReference,
|
||||||
|
getPreferredBadge,
|
||||||
i18n,
|
i18n,
|
||||||
interactionMode,
|
interactionMode,
|
||||||
kickOffAttachmentDownload,
|
kickOffAttachmentDownload,
|
||||||
|
@ -327,6 +328,7 @@ export class MessageDetail extends React.Component<Props> {
|
||||||
log.warn('MessageDetail: deleteMessageForEveryone called!')
|
log.warn('MessageDetail: deleteMessageForEveryone called!')
|
||||||
}
|
}
|
||||||
doubleCheckMissingQuoteReference={doubleCheckMissingQuoteReference}
|
doubleCheckMissingQuoteReference={doubleCheckMissingQuoteReference}
|
||||||
|
getPreferredBadge={getPreferredBadge}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
interactionMode={interactionMode}
|
interactionMode={interactionMode}
|
||||||
kickOffAttachmentDownload={kickOffAttachmentDownload}
|
kickOffAttachmentDownload={kickOffAttachmentDownload}
|
||||||
|
|
|
@ -37,7 +37,6 @@ const defaultMessageProps: MessagesProps = {
|
||||||
id: 'some-id',
|
id: 'some-id',
|
||||||
title: 'Person X',
|
title: 'Person X',
|
||||||
}),
|
}),
|
||||||
authorBadge: undefined,
|
|
||||||
canReply: true,
|
canReply: true,
|
||||||
canDeleteForEveryone: true,
|
canDeleteForEveryone: true,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
|
@ -56,6 +55,7 @@ const defaultMessageProps: MessagesProps = {
|
||||||
doubleCheckMissingQuoteReference: action(
|
doubleCheckMissingQuoteReference: action(
|
||||||
'default--doubleCheckMissingQuoteReference'
|
'default--doubleCheckMissingQuoteReference'
|
||||||
),
|
),
|
||||||
|
getPreferredBadge: () => undefined,
|
||||||
i18n,
|
i18n,
|
||||||
id: 'messageId',
|
id: 'messageId',
|
||||||
renderingContext: 'storybook',
|
renderingContext: 'storybook',
|
||||||
|
|
|
@ -11,17 +11,20 @@ import { ReactionViewer } from './ReactionViewer';
|
||||||
import { setupI18n } from '../../util/setupI18n';
|
import { setupI18n } from '../../util/setupI18n';
|
||||||
import enMessages from '../../../_locales/en/messages.json';
|
import enMessages from '../../../_locales/en/messages.json';
|
||||||
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
|
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
|
||||||
|
import { ThemeType } from '../../types/Util';
|
||||||
|
|
||||||
const i18n = setupI18n('en', enMessages);
|
const i18n = setupI18n('en', enMessages);
|
||||||
|
|
||||||
const story = storiesOf('Components/Conversation/ReactionViewer', module);
|
const story = storiesOf('Components/Conversation/ReactionViewer', module);
|
||||||
|
|
||||||
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
||||||
|
getPreferredBadge: () => undefined,
|
||||||
i18n,
|
i18n,
|
||||||
onClose: action('onClose'),
|
onClose: action('onClose'),
|
||||||
pickedReaction: overrideProps.pickedReaction,
|
pickedReaction: overrideProps.pickedReaction,
|
||||||
reactions: overrideProps.reactions || [],
|
reactions: overrideProps.reactions || [],
|
||||||
style: overrideProps.style,
|
style: overrideProps.style,
|
||||||
|
theme: ThemeType.light,
|
||||||
});
|
});
|
||||||
|
|
||||||
story.add('All Reactions', () => {
|
story.add('All Reactions', () => {
|
||||||
|
|
|
@ -10,9 +10,11 @@ import { Avatar } from '../Avatar';
|
||||||
import { Emoji } from '../emoji/Emoji';
|
import { Emoji } from '../emoji/Emoji';
|
||||||
import { useRestoreFocus } from '../../hooks/useRestoreFocus';
|
import { useRestoreFocus } from '../../hooks/useRestoreFocus';
|
||||||
import type { ConversationType } from '../../state/ducks/conversations';
|
import type { ConversationType } from '../../state/ducks/conversations';
|
||||||
|
import type { PreferredBadgeSelectorType } from '../../state/selectors/badges';
|
||||||
import type { EmojiData } from '../emoji/lib';
|
import type { EmojiData } from '../emoji/lib';
|
||||||
import { emojiToData } from '../emoji/lib';
|
import { emojiToData } from '../emoji/lib';
|
||||||
import { useEscapeHandling } from '../../hooks/useEscapeHandling';
|
import { useEscapeHandling } from '../../hooks/useEscapeHandling';
|
||||||
|
import type { ThemeType } from '../../types/Util';
|
||||||
|
|
||||||
export type Reaction = {
|
export type Reaction = {
|
||||||
emoji: string;
|
emoji: string;
|
||||||
|
@ -21,6 +23,7 @@ export type Reaction = {
|
||||||
ConversationType,
|
ConversationType,
|
||||||
| 'acceptedMessageRequest'
|
| 'acceptedMessageRequest'
|
||||||
| 'avatarPath'
|
| 'avatarPath'
|
||||||
|
| 'badges'
|
||||||
| 'color'
|
| 'color'
|
||||||
| 'id'
|
| 'id'
|
||||||
| 'isMe'
|
| 'isMe'
|
||||||
|
@ -33,9 +36,11 @@ export type Reaction = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type OwnProps = {
|
export type OwnProps = {
|
||||||
|
getPreferredBadge: PreferredBadgeSelectorType;
|
||||||
reactions: Array<Reaction>;
|
reactions: Array<Reaction>;
|
||||||
pickedReaction?: string;
|
pickedReaction?: string;
|
||||||
onClose?: () => unknown;
|
onClose?: () => unknown;
|
||||||
|
theme: ThemeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Props = OwnProps &
|
export type Props = OwnProps &
|
||||||
|
@ -62,7 +67,18 @@ type ReactionCategory = {
|
||||||
type ReactionWithEmojiData = Reaction & EmojiData;
|
type ReactionWithEmojiData = Reaction & EmojiData;
|
||||||
|
|
||||||
export const ReactionViewer = React.forwardRef<HTMLDivElement, Props>(
|
export const ReactionViewer = React.forwardRef<HTMLDivElement, Props>(
|
||||||
({ i18n, reactions, onClose, pickedReaction, ...rest }, ref) => {
|
(
|
||||||
|
{
|
||||||
|
getPreferredBadge,
|
||||||
|
i18n,
|
||||||
|
onClose,
|
||||||
|
pickedReaction,
|
||||||
|
reactions,
|
||||||
|
theme,
|
||||||
|
...rest
|
||||||
|
},
|
||||||
|
ref
|
||||||
|
) => {
|
||||||
const reactionsWithEmojiData = React.useMemo(
|
const reactionsWithEmojiData = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
reactions
|
reactions
|
||||||
|
@ -205,6 +221,7 @@ export const ReactionViewer = React.forwardRef<HTMLDivElement, Props>(
|
||||||
<Avatar
|
<Avatar
|
||||||
acceptedMessageRequest={from.acceptedMessageRequest}
|
acceptedMessageRequest={from.acceptedMessageRequest}
|
||||||
avatarPath={from.avatarPath}
|
avatarPath={from.avatarPath}
|
||||||
|
badge={getPreferredBadge(from.badges)}
|
||||||
conversationType="direct"
|
conversationType="direct"
|
||||||
sharedGroupNames={from.sharedGroupNames}
|
sharedGroupNames={from.sharedGroupNames}
|
||||||
size={32}
|
size={32}
|
||||||
|
@ -213,6 +230,7 @@ export const ReactionViewer = React.forwardRef<HTMLDivElement, Props>(
|
||||||
name={from.name}
|
name={from.name}
|
||||||
profileName={from.profileName}
|
profileName={from.profileName}
|
||||||
phoneNumber={from.phoneNumber}
|
phoneNumber={from.phoneNumber}
|
||||||
|
theme={theme}
|
||||||
title={from.title}
|
title={from.title}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -47,7 +47,6 @@ const items: Record<string, TimelineItemType> = {
|
||||||
author: getDefaultConversation({
|
author: getDefaultConversation({
|
||||||
phoneNumber: '(202) 555-2001',
|
phoneNumber: '(202) 555-2001',
|
||||||
}),
|
}),
|
||||||
authorBadge: undefined,
|
|
||||||
canDeleteForEveryone: false,
|
canDeleteForEveryone: false,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
canReply: true,
|
canReply: true,
|
||||||
|
@ -68,7 +67,6 @@ const items: Record<string, TimelineItemType> = {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
data: {
|
data: {
|
||||||
author: getDefaultConversation({}),
|
author: getDefaultConversation({}),
|
||||||
authorBadge: undefined,
|
|
||||||
canDeleteForEveryone: false,
|
canDeleteForEveryone: false,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
canReply: true,
|
canReply: true,
|
||||||
|
@ -102,7 +100,6 @@ const items: Record<string, TimelineItemType> = {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
data: {
|
data: {
|
||||||
author: getDefaultConversation({}),
|
author: getDefaultConversation({}),
|
||||||
authorBadge: undefined,
|
|
||||||
canDeleteForEveryone: false,
|
canDeleteForEveryone: false,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
canReply: true,
|
canReply: true,
|
||||||
|
@ -192,7 +189,6 @@ const items: Record<string, TimelineItemType> = {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
data: {
|
data: {
|
||||||
author: getDefaultConversation({}),
|
author: getDefaultConversation({}),
|
||||||
authorBadge: undefined,
|
|
||||||
canDeleteForEveryone: false,
|
canDeleteForEveryone: false,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
canReply: true,
|
canReply: true,
|
||||||
|
@ -214,7 +210,6 @@ const items: Record<string, TimelineItemType> = {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
data: {
|
data: {
|
||||||
author: getDefaultConversation({}),
|
author: getDefaultConversation({}),
|
||||||
authorBadge: undefined,
|
|
||||||
canDeleteForEveryone: false,
|
canDeleteForEveryone: false,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
canReply: true,
|
canReply: true,
|
||||||
|
@ -236,7 +231,6 @@ const items: Record<string, TimelineItemType> = {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
data: {
|
data: {
|
||||||
author: getDefaultConversation({}),
|
author: getDefaultConversation({}),
|
||||||
authorBadge: undefined,
|
|
||||||
canDeleteForEveryone: false,
|
canDeleteForEveryone: false,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
canReply: true,
|
canReply: true,
|
||||||
|
@ -258,7 +252,6 @@ const items: Record<string, TimelineItemType> = {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
data: {
|
data: {
|
||||||
author: getDefaultConversation({}),
|
author: getDefaultConversation({}),
|
||||||
authorBadge: undefined,
|
|
||||||
canDeleteForEveryone: false,
|
canDeleteForEveryone: false,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
canReply: true,
|
canReply: true,
|
||||||
|
@ -280,7 +273,6 @@ const items: Record<string, TimelineItemType> = {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
data: {
|
data: {
|
||||||
author: getDefaultConversation({}),
|
author: getDefaultConversation({}),
|
||||||
authorBadge: undefined,
|
|
||||||
canDeleteForEveryone: false,
|
canDeleteForEveryone: false,
|
||||||
canDownload: true,
|
canDownload: true,
|
||||||
canReply: true,
|
canReply: true,
|
||||||
|
@ -389,6 +381,7 @@ const renderItem = ({
|
||||||
containerWidthBreakpoint: WidthBreakpoint;
|
containerWidthBreakpoint: WidthBreakpoint;
|
||||||
}) => (
|
}) => (
|
||||||
<TimelineItem
|
<TimelineItem
|
||||||
|
getPreferredBadge={() => undefined}
|
||||||
id=""
|
id=""
|
||||||
isSelected={false}
|
isSelected={false}
|
||||||
renderEmojiPicker={() => <div />}
|
renderEmojiPicker={() => <div />}
|
||||||
|
|
|
@ -51,6 +51,7 @@ const getDefaultProps = () => ({
|
||||||
containerElementRef: React.createRef<HTMLElement>(),
|
containerElementRef: React.createRef<HTMLElement>(),
|
||||||
containerWidthBreakpoint: WidthBreakpoint.Wide,
|
containerWidthBreakpoint: WidthBreakpoint.Wide,
|
||||||
conversationId: 'conversation-id',
|
conversationId: 'conversation-id',
|
||||||
|
getPreferredBadge: () => undefined,
|
||||||
id: 'asdf',
|
id: 'asdf',
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
interactionMode: 'keyboard' as const,
|
interactionMode: 'keyboard' as const,
|
||||||
|
|
|
@ -165,6 +165,7 @@ export type PropsType = PropsLocalType &
|
||||||
Pick<
|
Pick<
|
||||||
AllMessageProps,
|
AllMessageProps,
|
||||||
| 'containerWidthBreakpoint'
|
| 'containerWidthBreakpoint'
|
||||||
|
| 'getPreferredBadge'
|
||||||
| 'renderEmojiPicker'
|
| 'renderEmojiPicker'
|
||||||
| 'renderAudioAttachment'
|
| 'renderAudioAttachment'
|
||||||
| 'renderReactionPicker'
|
| 'renderReactionPicker'
|
||||||
|
@ -175,6 +176,7 @@ export class TimelineItem extends React.PureComponent<PropsType> {
|
||||||
const {
|
const {
|
||||||
containerElementRef,
|
containerElementRef,
|
||||||
conversationId,
|
conversationId,
|
||||||
|
getPreferredBadge,
|
||||||
id,
|
id,
|
||||||
isSelected,
|
isSelected,
|
||||||
item,
|
item,
|
||||||
|
@ -201,6 +203,7 @@ export class TimelineItem extends React.PureComponent<PropsType> {
|
||||||
{...omit(this.props, ['item'])}
|
{...omit(this.props, ['item'])}
|
||||||
{...item.data}
|
{...item.data}
|
||||||
containerElementRef={containerElementRef}
|
containerElementRef={containerElementRef}
|
||||||
|
getPreferredBadge={getPreferredBadge}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
renderingContext="conversation/TimelineItem"
|
renderingContext="conversation/TimelineItem"
|
||||||
|
|
|
@ -134,8 +134,6 @@ import type { LinkPreviewType } from '../types/message/LinkPreviews';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import * as Bytes from '../Bytes';
|
import * as Bytes from '../Bytes';
|
||||||
import { computeHash } from '../Crypto';
|
import { computeHash } from '../Crypto';
|
||||||
import type { PreferredBadgeSelectorType } from '../state/selectors/badges';
|
|
||||||
import { getPreferredBadgeSelector } from '../state/selectors/badges';
|
|
||||||
|
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
/* eslint-disable more/no-then */
|
/* eslint-disable more/no-then */
|
||||||
|
@ -394,13 +392,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
ourConversationId,
|
ourConversationId,
|
||||||
ourNumber: window.textsecure.storage.user.getNumber(),
|
ourNumber: window.textsecure.storage.user.getNumber(),
|
||||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||||
preferredBadgeSelector: (
|
|
||||||
...args: Parameters<PreferredBadgeSelectorType>
|
|
||||||
) => {
|
|
||||||
const state = window.reduxStore.getState();
|
|
||||||
const preferredBadgeSelector = getPreferredBadgeSelector(state);
|
|
||||||
return preferredBadgeSelector(...args);
|
|
||||||
},
|
|
||||||
regionCode: window.storage.get('regionCode', 'ZZ'),
|
regionCode: window.storage.get('regionCode', 'ZZ'),
|
||||||
accountSelector: (identifier?: string) => {
|
accountSelector: (identifier?: string) => {
|
||||||
const state = window.reduxStore.getState();
|
const state = window.reduxStore.getState();
|
||||||
|
|
|
@ -49,8 +49,6 @@ import { getPinnedConversationIds } from './items';
|
||||||
import { getPropsForBubble } from './message';
|
import { getPropsForBubble } from './message';
|
||||||
import type { CallSelectorType, CallStateType } from './calling';
|
import type { CallSelectorType, CallStateType } from './calling';
|
||||||
import { getActiveCall, getCallSelector } from './calling';
|
import { getActiveCall, getCallSelector } from './calling';
|
||||||
import type { PreferredBadgeSelectorType } from './badges';
|
|
||||||
import { getPreferredBadgeSelector } from './badges';
|
|
||||||
import type { AccountSelectorType } from './accounts';
|
import type { AccountSelectorType } from './accounts';
|
||||||
import { getAccountSelector } from './accounts';
|
import { getAccountSelector } from './accounts';
|
||||||
import * as log from '../../logging/log';
|
import * as log from '../../logging/log';
|
||||||
|
@ -795,7 +793,6 @@ export const getMessageSelector = createSelector(
|
||||||
getMessages,
|
getMessages,
|
||||||
getSelectedMessage,
|
getSelectedMessage,
|
||||||
getConversationSelector,
|
getConversationSelector,
|
||||||
getPreferredBadgeSelector,
|
|
||||||
getRegionCode,
|
getRegionCode,
|
||||||
getUserNumber,
|
getUserNumber,
|
||||||
getUserUuid,
|
getUserUuid,
|
||||||
|
@ -809,7 +806,6 @@ export const getMessageSelector = createSelector(
|
||||||
messageLookup: MessageLookupType,
|
messageLookup: MessageLookupType,
|
||||||
selectedMessage: SelectedMessageType | undefined,
|
selectedMessage: SelectedMessageType | undefined,
|
||||||
conversationSelector: GetConversationByIdType,
|
conversationSelector: GetConversationByIdType,
|
||||||
preferredBadgeSelector: PreferredBadgeSelectorType,
|
|
||||||
regionCode: string,
|
regionCode: string,
|
||||||
ourNumber: string,
|
ourNumber: string,
|
||||||
ourUuid: UUIDStringType,
|
ourUuid: UUIDStringType,
|
||||||
|
@ -830,7 +826,6 @@ export const getMessageSelector = createSelector(
|
||||||
ourConversationId,
|
ourConversationId,
|
||||||
ourNumber,
|
ourNumber,
|
||||||
ourUuid,
|
ourUuid,
|
||||||
preferredBadgeSelector,
|
|
||||||
regionCode,
|
regionCode,
|
||||||
selectedMessageId: selectedMessage?.id,
|
selectedMessageId: selectedMessage?.id,
|
||||||
selectedMessageCounter: selectedMessage?.counter,
|
selectedMessageCounter: selectedMessage?.counter,
|
||||||
|
|
|
@ -63,7 +63,6 @@ import type {
|
||||||
} from '../ducks/conversations';
|
} from '../ducks/conversations';
|
||||||
|
|
||||||
import type { AccountSelectorType } from './accounts';
|
import type { AccountSelectorType } from './accounts';
|
||||||
import type { PreferredBadgeSelectorType } from './badges';
|
|
||||||
import type { CallSelectorType, CallStateType } from './calling';
|
import type { CallSelectorType, CallStateType } from './calling';
|
||||||
import type {
|
import type {
|
||||||
GetConversationByIdType,
|
GetConversationByIdType,
|
||||||
|
@ -82,7 +81,6 @@ import {
|
||||||
someSendStatus,
|
someSendStatus,
|
||||||
} from '../../messages/MessageSendState';
|
} from '../../messages/MessageSendState';
|
||||||
import * as log from '../../logging/log';
|
import * as log from '../../logging/log';
|
||||||
import type { BadgeType } from '../../badges/types';
|
|
||||||
|
|
||||||
const THREE_HOURS = 3 * 60 * 60 * 1000;
|
const THREE_HOURS = 3 * 60 * 60 * 1000;
|
||||||
|
|
||||||
|
@ -108,7 +106,6 @@ export type GetPropsForBubbleOptions = Readonly<{
|
||||||
ourConversationId: string;
|
ourConversationId: string;
|
||||||
ourNumber?: string;
|
ourNumber?: string;
|
||||||
ourUuid: UUIDStringType;
|
ourUuid: UUIDStringType;
|
||||||
preferredBadgeSelector: PreferredBadgeSelectorType;
|
|
||||||
selectedMessageId?: string;
|
selectedMessageId?: string;
|
||||||
selectedMessageCounter?: number;
|
selectedMessageCounter?: number;
|
||||||
regionCode: string;
|
regionCode: string;
|
||||||
|
@ -350,19 +347,6 @@ const getCachedAuthorForMessage = createSelectorCreator(memoizeByRoot, isEqual)(
|
||||||
(_, author): PropsData['author'] => author
|
(_, author): PropsData['author'] => author
|
||||||
);
|
);
|
||||||
|
|
||||||
const getAuthorBadgeForMessage: (
|
|
||||||
message: MessageWithUIFieldsType,
|
|
||||||
options: {
|
|
||||||
preferredBadgeSelector: PreferredBadgeSelectorType;
|
|
||||||
}
|
|
||||||
) => undefined | BadgeType = createSelectorCreator(memoizeByRoot, isEqual)(
|
|
||||||
// `memoizeByRoot` requirement
|
|
||||||
identity,
|
|
||||||
(_, { preferredBadgeSelector }) => preferredBadgeSelector,
|
|
||||||
getAuthorForMessage,
|
|
||||||
(_, preferredBadgeSelector, author) => preferredBadgeSelector(author.badges)
|
|
||||||
);
|
|
||||||
|
|
||||||
export const getPreviewsForMessage = createSelectorCreator(memoizeByRoot)(
|
export const getPreviewsForMessage = createSelectorCreator(memoizeByRoot)(
|
||||||
// `memoizeByRoot` requirement
|
// `memoizeByRoot` requirement
|
||||||
identity,
|
identity,
|
||||||
|
@ -412,6 +396,7 @@ export const getReactionsForMessage = createSelectorCreator(
|
||||||
const unsafe = pick(c, [
|
const unsafe = pick(c, [
|
||||||
'acceptedMessageRequest',
|
'acceptedMessageRequest',
|
||||||
'avatarPath',
|
'avatarPath',
|
||||||
|
'badges',
|
||||||
'color',
|
'color',
|
||||||
'id',
|
'id',
|
||||||
'isMe',
|
'isMe',
|
||||||
|
@ -514,7 +499,6 @@ export type GetPropsForMessageOptions = Pick<
|
||||||
| 'ourConversationId'
|
| 'ourConversationId'
|
||||||
| 'ourUuid'
|
| 'ourUuid'
|
||||||
| 'ourNumber'
|
| 'ourNumber'
|
||||||
| 'preferredBadgeSelector'
|
|
||||||
| 'selectedMessageId'
|
| 'selectedMessageId'
|
||||||
| 'selectedMessageCounter'
|
| 'selectedMessageCounter'
|
||||||
| 'regionCode'
|
| 'regionCode'
|
||||||
|
@ -656,7 +640,6 @@ export const getPropsForMessage: (
|
||||||
getAttachmentsForMessage,
|
getAttachmentsForMessage,
|
||||||
processBodyRanges,
|
processBodyRanges,
|
||||||
getCachedAuthorForMessage,
|
getCachedAuthorForMessage,
|
||||||
getAuthorBadgeForMessage,
|
|
||||||
getPreviewsForMessage,
|
getPreviewsForMessage,
|
||||||
getReactionsForMessage,
|
getReactionsForMessage,
|
||||||
getPropsForQuote,
|
getPropsForQuote,
|
||||||
|
@ -666,7 +649,6 @@ export const getPropsForMessage: (
|
||||||
attachments: Array<AttachmentType>,
|
attachments: Array<AttachmentType>,
|
||||||
bodyRanges: BodyRangesType | undefined,
|
bodyRanges: BodyRangesType | undefined,
|
||||||
author: PropsData['author'],
|
author: PropsData['author'],
|
||||||
authorBadge: undefined | BadgeType,
|
|
||||||
previews: Array<LinkPreviewType>,
|
previews: Array<LinkPreviewType>,
|
||||||
reactions: PropsData['reactions'],
|
reactions: PropsData['reactions'],
|
||||||
quote: PropsData['quote'],
|
quote: PropsData['quote'],
|
||||||
|
@ -675,7 +657,6 @@ export const getPropsForMessage: (
|
||||||
return {
|
return {
|
||||||
attachments,
|
attachments,
|
||||||
author,
|
author,
|
||||||
authorBadge,
|
|
||||||
bodyRanges,
|
bodyRanges,
|
||||||
previews,
|
previews,
|
||||||
quote,
|
quote,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { mapDispatchToProps } from '../actions';
|
||||||
import type { StateType } from '../reducer';
|
import type { StateType } from '../reducer';
|
||||||
|
|
||||||
import { TimelineItem } from '../../components/conversation/TimelineItem';
|
import { TimelineItem } from '../../components/conversation/TimelineItem';
|
||||||
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
||||||
import { getIntl, getInteractionMode, getTheme } from '../selectors/user';
|
import { getIntl, getInteractionMode, getTheme } from '../selectors/user';
|
||||||
import {
|
import {
|
||||||
getConversationSelector,
|
getConversationSelector,
|
||||||
|
@ -68,6 +69,7 @@ const mapStateToProps = (state: StateType, props: ExternalProps) => {
|
||||||
conversationId,
|
conversationId,
|
||||||
conversationColor: conversation?.conversationColor,
|
conversationColor: conversation?.conversationColor,
|
||||||
customColor: conversation?.customColor,
|
customColor: conversation?.customColor,
|
||||||
|
getPreferredBadge: getPreferredBadgeSelector(state),
|
||||||
isSelected,
|
isSelected,
|
||||||
renderContact,
|
renderContact,
|
||||||
renderUniversalTimerNotification,
|
renderUniversalTimerNotification,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue