Added last-message's author to group conversation list in left pane

This commit is contained in:
Alvaro 2022-08-25 10:16:37 -06:00 committed by GitHub
parent eadef45290
commit ca6300a86a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 5 deletions

View file

@ -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,

View file

@ -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'),
});
}