Fix left pane draft display and GV2 typing indicators

This commit is contained in:
Scott Nonnenberg 2020-11-03 16:16:20 -08:00 committed by GitHub
parent ab89c6c704
commit 18c71b291c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 31 deletions

View file

@ -103,6 +103,27 @@ story.add('Typing Status', () => {
return <ConversationListItem {...props} />;
});
story.add('With draft', () => {
const props = createProps({
shouldShowDraft: true,
draftPreview: "I'm in the middle of typing this...",
});
return <ConversationListItem {...props} />;
});
story.add('Deleted for everyone', () => {
const props = createProps({
lastMessage: {
status: 'sent',
text: 'You should not see this!',
deletedForEveryone: true,
},
});
return <ConversationListItem {...props} />;
});
story.add('Message Request', () => {
const props = createProps({
acceptedMessageRequest: false,

View file

@ -178,23 +178,14 @@ export class ConversationListItem extends React.PureComponent<Props> {
return null;
}
const messageBody = lastMessage ? lastMessage.text : '';
const withUnread = isNumber(unreadCount) && unreadCount > 0;
const showingDraft = shouldShowDraft && draftPreview;
const deletedForEveryone = Boolean(
lastMessage && lastMessage.deletedForEveryone
);
// Note: instead of re-using showingDraft here we explode it because
// typescript can't tell that draftPreview is truthy otherwise
// Avoiding touching logic to fix linting
/* eslint-disable no-nested-ternary */
const text =
shouldShowDraft && draftPreview
? draftPreview
: lastMessage && lastMessage.text
? lastMessage.text
: '';
return (
<div className="module-conversation-list-item__message">
<div
@ -218,16 +209,24 @@ export class ConversationListItem extends React.PureComponent<Props> {
) : (
<>
{showingDraft ? (
<span className="module-conversation-list-item__message__draft-prefix">
{i18n('ConversationListItem--draft-prefix')}
</span>
<>
<span className="module-conversation-list-item__message__draft-prefix">
{i18n('ConversationListItem--draft-prefix')}
</span>
<MessageBody
text={(draftPreview || '').split('\n')[0]}
disableJumbomoji
disableLinks
i18n={i18n}
/>
</>
) : deletedForEveryone ? (
<span className="module-conversation-list-item__message__deleted-for-everyone">
{i18n('message--deletedForEveryone')}
</span>
) : (
<MessageBody
text={text.split('\n')[0]}
text={(messageBody || '').split('\n')[0]}
disableJumbomoji
disableLinks
i18n={i18n}

View file

@ -422,8 +422,8 @@ export class Lightbox extends React.Component<Props, State> {
const { contentType } = this.props;
// These are the only image types supported by Electron's NativeImage
if (contentType !== 'image/png' && contentType !== 'image/jpg') {
event?.preventDefault();
if (event && contentType !== 'image/png' && contentType !== 'image/jpg') {
event.preventDefault();
}
};