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;
|
background-color: $color-black-alpha-40;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__author {
|
||||||
|
@include font-body-2-bold;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ type OpenConversationActionType = (
|
||||||
export type Props = {
|
export type Props = {
|
||||||
direction?: 'incoming' | 'outgoing';
|
direction?: 'incoming' | 'outgoing';
|
||||||
text: string;
|
text: string;
|
||||||
|
author?: string;
|
||||||
textAttachment?: Pick<AttachmentType, 'pending' | 'digest' | 'key'>;
|
textAttachment?: Pick<AttachmentType, 'pending' | 'digest' | 'key'>;
|
||||||
/** If set, all emoji will be the same size. Otherwise, just one emoji will be large. */
|
/** If set, all emoji will be the same size. Otherwise, just one emoji will be large. */
|
||||||
disableJumbomoji?: boolean;
|
disableJumbomoji?: boolean;
|
||||||
|
@ -74,6 +75,7 @@ export function MessageBody({
|
||||||
onIncreaseTextLength,
|
onIncreaseTextLength,
|
||||||
openConversation,
|
openConversation,
|
||||||
text,
|
text,
|
||||||
|
author,
|
||||||
textAttachment,
|
textAttachment,
|
||||||
kickOffBodyDownload,
|
kickOffBodyDownload,
|
||||||
}: Props): JSX.Element {
|
}: Props): JSX.Element {
|
||||||
|
@ -144,6 +146,20 @@ export function MessageBody({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
|
{author && (
|
||||||
|
<>
|
||||||
|
<span className="MessageBody__author">
|
||||||
|
{renderEmoji({
|
||||||
|
i18n,
|
||||||
|
text: author,
|
||||||
|
sizeClass,
|
||||||
|
key: 0,
|
||||||
|
renderNonEmoji: renderNewLines,
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
:{' '}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{disableLinks ? (
|
{disableLinks ? (
|
||||||
renderEmoji({
|
renderEmoji({
|
||||||
i18n,
|
i18n,
|
||||||
|
|
|
@ -148,6 +148,7 @@ export const ConversationListItem: FunctionComponent<Props> = React.memo(
|
||||||
messageText = (
|
messageText = (
|
||||||
<MessageBody
|
<MessageBody
|
||||||
text={truncateMessageText(lastMessage.text)}
|
text={truncateMessageText(lastMessage.text)}
|
||||||
|
author={type === 'group' ? lastMessage.author : undefined}
|
||||||
disableJumbomoji
|
disableJumbomoji
|
||||||
disableLinks
|
disableLinks
|
||||||
i18n={i18n}
|
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;
|
isPinned?: boolean;
|
||||||
lastMessageDeletedForEveryone?: boolean;
|
lastMessageDeletedForEveryone?: boolean;
|
||||||
lastMessageStatus?: LastMessageStatus | null;
|
lastMessageStatus?: LastMessageStatus | null;
|
||||||
|
lastMessageAuthor?: string | null;
|
||||||
markedUnread?: boolean;
|
markedUnread?: boolean;
|
||||||
messageCount?: number;
|
messageCount?: number;
|
||||||
messageCountBeforeMessageRequests?: number | null;
|
messageCountBeforeMessageRequests?: number | null;
|
||||||
|
|
|
@ -1703,6 +1703,7 @@ export class ConversationModel extends window.Backbone
|
||||||
| {
|
| {
|
||||||
status?: LastMessageStatus;
|
status?: LastMessageStatus;
|
||||||
text: string;
|
text: string;
|
||||||
|
author?: string;
|
||||||
deletedForEveryone: false;
|
deletedForEveryone: false;
|
||||||
}
|
}
|
||||||
| { deletedForEveryone: true };
|
| { deletedForEveryone: true };
|
||||||
|
@ -1715,6 +1716,7 @@ export class ConversationModel extends window.Backbone
|
||||||
lastMessage = {
|
lastMessage = {
|
||||||
status: dropNull(this.get('lastMessageStatus')),
|
status: dropNull(this.get('lastMessageStatus')),
|
||||||
text: lastMessageText,
|
text: lastMessageText,
|
||||||
|
author: dropNull(this.get('lastMessageAuthor')),
|
||||||
deletedForEveryone: false,
|
deletedForEveryone: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -3992,6 +3994,7 @@ export class ConversationModel extends window.Backbone
|
||||||
draft: null,
|
draft: null,
|
||||||
draftTimestamp: null,
|
draftTimestamp: null,
|
||||||
lastMessage: model.getNotificationText(),
|
lastMessage: model.getNotificationText(),
|
||||||
|
lastMessageAuthor: model.getAuthorText(),
|
||||||
lastMessageStatus: 'sending' as const,
|
lastMessageStatus: 'sending' as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4121,6 +4124,7 @@ export class ConversationModel extends window.Backbone
|
||||||
this.set({
|
this.set({
|
||||||
lastMessage:
|
lastMessage:
|
||||||
(previewMessage ? previewMessage.getNotificationText() : '') || '',
|
(previewMessage ? previewMessage.getNotificationText() : '') || '',
|
||||||
|
lastMessageAuthor: previewMessage?.getAuthorText(),
|
||||||
lastMessageStatus:
|
lastMessageStatus:
|
||||||
(previewMessage
|
(previewMessage
|
||||||
? getMessagePropStatus(previewMessage.attributes, ourConversationId)
|
? getMessagePropStatus(previewMessage.attributes, ourConversationId)
|
||||||
|
@ -4875,6 +4879,7 @@ export class ConversationModel extends window.Backbone
|
||||||
async destroyMessages(): Promise<void> {
|
async destroyMessages(): Promise<void> {
|
||||||
this.set({
|
this.set({
|
||||||
lastMessage: null,
|
lastMessage: null,
|
||||||
|
lastMessageAuthor: null,
|
||||||
timestamp: null,
|
timestamp: null,
|
||||||
active_at: null,
|
active_at: null,
|
||||||
pendingUniversalTimer: undefined,
|
pendingUniversalTimer: undefined,
|
||||||
|
|
|
@ -833,6 +833,17 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
return body;
|
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 {
|
getNotificationText(): string {
|
||||||
const { text, emoji } = this.getNotificationData();
|
const { text, emoji } = this.getNotificationData();
|
||||||
const { attributes } = this;
|
const { attributes } = this;
|
||||||
|
@ -1258,12 +1269,12 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
if (!isIncoming(this.attributes)) {
|
if (!isIncoming(this.attributes)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const source = this.get('source');
|
const sourceUuid = this.get('sourceUuid');
|
||||||
if (!source) {
|
if (!sourceUuid) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return window.ConversationController.getOrCreate(source, 'private');
|
return window.ConversationController.getOrCreate(sourceUuid, 'private');
|
||||||
}
|
}
|
||||||
|
|
||||||
async retrySend(): Promise<void> {
|
async retrySend(): Promise<void> {
|
||||||
|
@ -2723,6 +2734,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
) {
|
) {
|
||||||
conversation.set({
|
conversation.set({
|
||||||
lastMessage: message.getNotificationText(),
|
lastMessage: message.getNotificationText(),
|
||||||
|
lastMessageAuthor: message.getAuthorText(),
|
||||||
timestamp: message.get('sent_at'),
|
timestamp: message.get('sent_at'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,7 @@ export type ConversationType = {
|
||||||
| {
|
| {
|
||||||
status?: LastMessageStatus;
|
status?: LastMessageStatus;
|
||||||
text: string;
|
text: string;
|
||||||
|
author?: string;
|
||||||
deletedForEveryone: false;
|
deletedForEveryone: false;
|
||||||
}
|
}
|
||||||
| { deletedForEveryone: true };
|
| { deletedForEveryone: true };
|
||||||
|
|
|
@ -125,7 +125,7 @@ const LAST_MESSAGE = 'start sending messages now';
|
||||||
const item = leftPane.locator(
|
const item = leftPane.locator(
|
||||||
'_react=BaseConversationListItem' +
|
'_react=BaseConversationListItem' +
|
||||||
`[title = ${JSON.stringify(group.title)}] ` +
|
`[title = ${JSON.stringify(group.title)}] ` +
|
||||||
`>> ${JSON.stringify(LAST_MESSAGE)}`
|
`>> text=${LAST_MESSAGE}`
|
||||||
);
|
);
|
||||||
await item.click();
|
await item.click();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue