Show mentioned badges & enable scrolling to mentions in conversations
This commit is contained in:
parent
caaeda8abe
commit
d012779e87
21 changed files with 694 additions and 184 deletions
|
@ -2056,6 +2056,7 @@ export class ConversationModel extends window.Backbone
|
|||
? window.i18n('icu:noteToSelf')
|
||||
: this.getTitle(),
|
||||
unreadCount: this.get('unreadCount') || 0,
|
||||
unreadMentionsCount: this.get('unreadMentionsCount'),
|
||||
...(isDirectConversation(this.attributes)
|
||||
? {
|
||||
type: 'direct' as const,
|
||||
|
@ -4913,17 +4914,28 @@ export class ConversationModel extends window.Backbone
|
|||
}
|
||||
|
||||
async updateUnread(): Promise<void> {
|
||||
const unreadCount = await window.Signal.Data.getTotalUnreadForConversation(
|
||||
this.id,
|
||||
{
|
||||
storyId: undefined,
|
||||
includeStoryReplies: !isGroup(this.attributes),
|
||||
}
|
||||
);
|
||||
const options = {
|
||||
storyId: undefined,
|
||||
includeStoryReplies: !isGroup(this.attributes),
|
||||
};
|
||||
const [unreadCount, unreadMentionsCount] = await Promise.all([
|
||||
window.Signal.Data.getTotalUnreadForConversation(this.id, options),
|
||||
window.Signal.Data.getTotalUnreadMentionsOfMeForConversation(
|
||||
this.id,
|
||||
options
|
||||
),
|
||||
]);
|
||||
|
||||
const prevUnreadCount = this.get('unreadCount');
|
||||
if (prevUnreadCount !== unreadCount) {
|
||||
this.set({ unreadCount });
|
||||
const prevUnreadMentionsCount = this.get('unreadMentionsCount');
|
||||
if (
|
||||
prevUnreadCount !== unreadCount ||
|
||||
prevUnreadMentionsCount !== unreadMentionsCount
|
||||
) {
|
||||
this.set({
|
||||
unreadCount,
|
||||
unreadMentionsCount,
|
||||
});
|
||||
window.Signal.Data.updateConversation(this.attributes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2575,6 +2575,14 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
);
|
||||
}
|
||||
|
||||
const ourPNI = window.textsecure.storage.user.getCheckedUuid(
|
||||
UUIDKind.PNI
|
||||
);
|
||||
const ourUuids: Set<string> = new Set([
|
||||
ourACI.toString(),
|
||||
ourPNI.toString(),
|
||||
]);
|
||||
|
||||
message.set({
|
||||
id: messageId,
|
||||
attachments: dataMessage.attachments,
|
||||
|
@ -2590,6 +2598,12 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
hasFileAttachments: dataMessage.hasFileAttachments,
|
||||
hasVisualMediaAttachments: dataMessage.hasVisualMediaAttachments,
|
||||
isViewOnce: Boolean(dataMessage.isViewOnce),
|
||||
mentionsMe: (dataMessage.bodyRanges ?? []).some(bodyRange => {
|
||||
if (!BodyRange.isMention(bodyRange)) {
|
||||
return false;
|
||||
}
|
||||
return ourUuids.has(bodyRange.mentionUuid);
|
||||
}),
|
||||
preview,
|
||||
requiredProtocolVersion:
|
||||
dataMessage.requiredProtocolVersion ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue