Added last-message's author to group conversation list in left pane
This commit is contained in:
parent
eadef45290
commit
ca6300a86a
8 changed files with 45 additions and 5 deletions
|
@ -54,4 +54,8 @@
|
|||
background-color: $color-black-alpha-40;
|
||||
}
|
||||
}
|
||||
|
||||
&__author {
|
||||
@include font-body-2-bold;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ type OpenConversationActionType = (
|
|||
export type Props = {
|
||||
direction?: 'incoming' | 'outgoing';
|
||||
text: string;
|
||||
author?: string;
|
||||
textAttachment?: Pick<AttachmentType, 'pending' | 'digest' | 'key'>;
|
||||
/** If set, all emoji will be the same size. Otherwise, just one emoji will be large. */
|
||||
disableJumbomoji?: boolean;
|
||||
|
@ -74,6 +75,7 @@ export function MessageBody({
|
|||
onIncreaseTextLength,
|
||||
openConversation,
|
||||
text,
|
||||
author,
|
||||
textAttachment,
|
||||
kickOffBodyDownload,
|
||||
}: Props): JSX.Element {
|
||||
|
@ -144,6 +146,20 @@ export function MessageBody({
|
|||
|
||||
return (
|
||||
<span>
|
||||
{author && (
|
||||
<>
|
||||
<span className="MessageBody__author">
|
||||
{renderEmoji({
|
||||
i18n,
|
||||
text: author,
|
||||
sizeClass,
|
||||
key: 0,
|
||||
renderNonEmoji: renderNewLines,
|
||||
})}
|
||||
</span>
|
||||
:{' '}
|
||||
</>
|
||||
)}
|
||||
{disableLinks ? (
|
||||
renderEmoji({
|
||||
i18n,
|
||||
|
|
|
@ -148,6 +148,7 @@ export const ConversationListItem: FunctionComponent<Props> = React.memo(
|
|||
messageText = (
|
||||
<MessageBody
|
||||
text={truncateMessageText(lastMessage.text)}
|
||||
author={type === 'group' ? lastMessage.author : undefined}
|
||||
disableJumbomoji
|
||||
disableLinks
|
||||
i18n={i18n}
|
||||
|
|
1
ts/model-types.d.ts
vendored
1
ts/model-types.d.ts
vendored
|
@ -281,6 +281,7 @@ export type ConversationAttributesType = {
|
|||
isPinned?: boolean;
|
||||
lastMessageDeletedForEveryone?: boolean;
|
||||
lastMessageStatus?: LastMessageStatus | null;
|
||||
lastMessageAuthor?: string | null;
|
||||
markedUnread?: boolean;
|
||||
messageCount?: number;
|
||||
messageCountBeforeMessageRequests?: number | null;
|
||||
|
|
|
@ -1703,6 +1703,7 @@ export class ConversationModel extends window.Backbone
|
|||
| {
|
||||
status?: LastMessageStatus;
|
||||
text: string;
|
||||
author?: string;
|
||||
deletedForEveryone: false;
|
||||
}
|
||||
| { deletedForEveryone: true };
|
||||
|
@ -1715,6 +1716,7 @@ export class ConversationModel extends window.Backbone
|
|||
lastMessage = {
|
||||
status: dropNull(this.get('lastMessageStatus')),
|
||||
text: lastMessageText,
|
||||
author: dropNull(this.get('lastMessageAuthor')),
|
||||
deletedForEveryone: false,
|
||||
};
|
||||
}
|
||||
|
@ -3992,6 +3994,7 @@ export class ConversationModel extends window.Backbone
|
|||
draft: null,
|
||||
draftTimestamp: null,
|
||||
lastMessage: model.getNotificationText(),
|
||||
lastMessageAuthor: model.getAuthorText(),
|
||||
lastMessageStatus: 'sending' as const,
|
||||
};
|
||||
|
||||
|
@ -4121,6 +4124,7 @@ export class ConversationModel extends window.Backbone
|
|||
this.set({
|
||||
lastMessage:
|
||||
(previewMessage ? previewMessage.getNotificationText() : '') || '',
|
||||
lastMessageAuthor: previewMessage?.getAuthorText(),
|
||||
lastMessageStatus:
|
||||
(previewMessage
|
||||
? getMessagePropStatus(previewMessage.attributes, ourConversationId)
|
||||
|
@ -4875,6 +4879,7 @@ export class ConversationModel extends window.Backbone
|
|||
async destroyMessages(): Promise<void> {
|
||||
this.set({
|
||||
lastMessage: null,
|
||||
lastMessageAuthor: null,
|
||||
timestamp: null,
|
||||
active_at: null,
|
||||
pendingUniversalTimer: undefined,
|
||||
|
|
|
@ -833,6 +833,17 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
return body;
|
||||
}
|
||||
|
||||
getAuthorText(): string | undefined {
|
||||
// if it's outgoing, it must be self-authored
|
||||
const selfAuthor = isOutgoing(this.attributes)
|
||||
? window.i18n('you')
|
||||
: undefined;
|
||||
|
||||
// if it's not selfAuthor and there's no incoming contact,
|
||||
// it might be a group notification, so we return undefined
|
||||
return selfAuthor ?? this.getIncomingContact()?.getTitle();
|
||||
}
|
||||
|
||||
getNotificationText(): string {
|
||||
const { text, emoji } = this.getNotificationData();
|
||||
const { attributes } = this;
|
||||
|
@ -1258,12 +1269,12 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
if (!isIncoming(this.attributes)) {
|
||||
return null;
|
||||
}
|
||||
const source = this.get('source');
|
||||
if (!source) {
|
||||
const sourceUuid = this.get('sourceUuid');
|
||||
if (!sourceUuid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return window.ConversationController.getOrCreate(source, 'private');
|
||||
return window.ConversationController.getOrCreate(sourceUuid, 'private');
|
||||
}
|
||||
|
||||
async retrySend(): Promise<void> {
|
||||
|
@ -2723,6 +2734,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
) {
|
||||
conversation.set({
|
||||
lastMessage: message.getNotificationText(),
|
||||
lastMessageAuthor: message.getAuthorText(),
|
||||
timestamp: message.get('sent_at'),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -150,6 +150,7 @@ export type ConversationType = {
|
|||
| {
|
||||
status?: LastMessageStatus;
|
||||
text: string;
|
||||
author?: string;
|
||||
deletedForEveryone: false;
|
||||
}
|
||||
| { deletedForEveryone: true };
|
||||
|
|
|
@ -125,7 +125,7 @@ const LAST_MESSAGE = 'start sending messages now';
|
|||
const item = leftPane.locator(
|
||||
'_react=BaseConversationListItem' +
|
||||
`[title = ${JSON.stringify(group.title)}] ` +
|
||||
`>> ${JSON.stringify(LAST_MESSAGE)}`
|
||||
`>> text=${LAST_MESSAGE}`
|
||||
);
|
||||
await item.click();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue