Remove messageCollection from Conversation model

This commit is contained in:
Scott Nonnenberg 2021-06-15 17:44:14 -07:00 committed by GitHub
parent 61ad1231df
commit 1520c80013
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 332 additions and 431 deletions

View file

@ -47,8 +47,6 @@ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
}),
isOutgoingKeyError: false,
isUnidentifiedDelivery: false,
onSendAnyway: action('onSendAnyway'),
onShowSafetyNumber: action('onShowSafetyNumber'),
status: 'delivered',
},
],
@ -60,6 +58,9 @@ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n,
interactionMode: 'keyboard',
sendAnyway: action('onSendAnyway'),
showSafetyNumber: action('onShowSafetyNumber'),
clearSelectedMessage: () => null,
deleteMessage: action('deleteMessage'),
deleteMessageForEveryone: action('deleteMessageForEveryone'),
@ -108,8 +109,6 @@ story.add('Message Statuses', () => {
}),
isOutgoingKeyError: false,
isUnidentifiedDelivery: false,
onSendAnyway: action('onSendAnyway'),
onShowSafetyNumber: action('onShowSafetyNumber'),
status: 'sent',
},
{
@ -119,8 +118,6 @@ story.add('Message Statuses', () => {
}),
isOutgoingKeyError: false,
isUnidentifiedDelivery: false,
onSendAnyway: action('onSendAnyway'),
onShowSafetyNumber: action('onShowSafetyNumber'),
status: 'sending',
},
{
@ -130,8 +127,6 @@ story.add('Message Statuses', () => {
}),
isOutgoingKeyError: false,
isUnidentifiedDelivery: false,
onSendAnyway: action('onSendAnyway'),
onShowSafetyNumber: action('onShowSafetyNumber'),
status: 'partial-sent',
},
{
@ -141,8 +136,6 @@ story.add('Message Statuses', () => {
}),
isOutgoingKeyError: false,
isUnidentifiedDelivery: false,
onSendAnyway: action('onSendAnyway'),
onShowSafetyNumber: action('onShowSafetyNumber'),
status: 'delivered',
},
{
@ -152,8 +145,6 @@ story.add('Message Statuses', () => {
}),
isOutgoingKeyError: false,
isUnidentifiedDelivery: false,
onSendAnyway: action('onSendAnyway'),
onShowSafetyNumber: action('onShowSafetyNumber'),
status: 'read',
},
],
@ -211,8 +202,6 @@ story.add('All Errors', () => {
}),
isOutgoingKeyError: true,
isUnidentifiedDelivery: false,
onSendAnyway: action('onSendAnyway'),
onShowSafetyNumber: action('onShowSafetyNumber'),
status: 'error',
},
{
@ -228,8 +217,6 @@ story.add('All Errors', () => {
],
isOutgoingKeyError: false,
isUnidentifiedDelivery: true,
onSendAnyway: action('onSendAnyway'),
onShowSafetyNumber: action('onShowSafetyNumber'),
status: 'error',
},
{
@ -239,8 +226,6 @@ story.add('All Errors', () => {
}),
isOutgoingKeyError: true,
isUnidentifiedDelivery: true,
onSendAnyway: action('onSendAnyway'),
onShowSafetyNumber: action('onShowSafetyNumber'),
status: 'error',
},
],

View file

@ -24,6 +24,7 @@ export type Contact = Pick<
| 'acceptedMessageRequest'
| 'avatarPath'
| 'color'
| 'id'
| 'isMe'
| 'name'
| 'phoneNumber'
@ -39,9 +40,6 @@ export type Contact = Pick<
unblurredAvatarPath?: string;
errors?: Array<Error>;
onSendAnyway: () => void;
onShowSafetyNumber: () => void;
};
export type Props = {
@ -52,6 +50,8 @@ export type Props = {
receivedAt: number;
sentAt: number;
sendAnyway: (contactId: string, messageId: string) => unknown;
showSafetyNumber: (contactId: string) => void;
i18n: LocalizerType;
} & Pick<
MessagePropsType,
@ -148,7 +148,7 @@ export class MessageDetail extends React.Component<Props> {
}
public renderContact(contact: Contact): JSX.Element {
const { i18n } = this.props;
const { i18n, message, showSafetyNumber, sendAnyway } = this.props;
const errors = contact.errors || [];
const errorComponent = contact.isOutgoingKeyError ? (
@ -156,14 +156,14 @@ export class MessageDetail extends React.Component<Props> {
<button
type="button"
className="module-message-detail__contact__show-safety-number"
onClick={contact.onShowSafetyNumber}
onClick={() => showSafetyNumber(contact.id)}
>
{i18n('showSafetyNumber')}
</button>
<button
type="button"
className="module-message-detail__contact__send-anyway"
onClick={contact.onSendAnyway}
onClick={() => sendAnyway(contact.id, message.id)}
>
{i18n('sendAnyway')}
</button>