Drop story replies from group timeline
This commit is contained in:
parent
e5ba00b798
commit
774246b6e2
10 changed files with 358 additions and 33 deletions
|
@ -85,6 +85,7 @@ import * as universalExpireTimer from '../util/universalExpireTimer';
|
|||
import type { GroupNameCollisionsWithIdsByTitle } from '../util/groupMemberNameCollisions';
|
||||
import {
|
||||
isDirectConversation,
|
||||
isGroup,
|
||||
isGroupV1,
|
||||
isGroupV2,
|
||||
isMe,
|
||||
|
@ -1375,10 +1376,16 @@ export class ConversationModel extends window.Backbone
|
|||
// Clear typing indicator for a given contact if we receive a message from them
|
||||
this.clearContactTypingTimer(typingToken);
|
||||
|
||||
if (!isStory(message.attributes)) {
|
||||
this.addSingleMessage(message);
|
||||
// If it's a group story reply or a story message, we don't want to update
|
||||
// the last message or add new messages to redux.
|
||||
const isGroupStoryReply =
|
||||
isGroup(this.attributes) && message.get('storyId');
|
||||
if (isGroupStoryReply || isStory(message.attributes)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.addSingleMessage(message);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this.debouncedUpdateLastMessage!();
|
||||
}
|
||||
|
@ -1486,7 +1493,11 @@ export class ConversationModel extends window.Backbone
|
|||
}
|
||||
}
|
||||
|
||||
const metrics = await getMessageMetricsForConversation(conversationId);
|
||||
const metrics = await getMessageMetricsForConversation(
|
||||
conversationId,
|
||||
undefined,
|
||||
isGroup(this.attributes)
|
||||
);
|
||||
|
||||
// If this is a message request that has not yet been accepted, we always show the
|
||||
// oldest messages, to ensure that the ConversationHero is shown. We don't want to
|
||||
|
@ -1505,6 +1516,7 @@ export class ConversationModel extends window.Backbone
|
|||
}
|
||||
|
||||
const messages = await getOlderMessagesByConversation(conversationId, {
|
||||
isGroup: isGroup(this.attributes),
|
||||
limit: MESSAGE_LOAD_CHUNK_SIZE,
|
||||
});
|
||||
|
||||
|
@ -1556,6 +1568,7 @@ export class ConversationModel extends window.Backbone
|
|||
const receivedAt = message.received_at;
|
||||
const sentAt = message.sent_at;
|
||||
const models = await getOlderMessagesByConversation(conversationId, {
|
||||
isGroup: isGroup(this.attributes),
|
||||
receivedAt,
|
||||
sentAt,
|
||||
messageId: oldestMessageId,
|
||||
|
@ -1609,6 +1622,7 @@ export class ConversationModel extends window.Backbone
|
|||
const receivedAt = message.received_at;
|
||||
const sentAt = message.sent_at;
|
||||
const models = await getNewerMessagesByConversation(conversationId, {
|
||||
isGroup: isGroup(this.attributes),
|
||||
receivedAt,
|
||||
sentAt,
|
||||
limit: MESSAGE_LOAD_CHUNK_SIZE,
|
||||
|
@ -2047,6 +2061,7 @@ export class ConversationModel extends window.Backbone
|
|||
messages = await window.Signal.Data.getOlderMessagesByConversation(
|
||||
this.get('id'),
|
||||
{
|
||||
isGroup: isGroup(this.attributes),
|
||||
limit: 100,
|
||||
receivedAt: first ? first.received_at : undefined,
|
||||
sentAt: first ? first.sent_at : undefined,
|
||||
|
@ -4186,6 +4201,7 @@ export class ConversationModel extends window.Backbone
|
|||
const ourUuid = window.textsecure.storage.user.getCheckedUuid().toString();
|
||||
const stats = await window.Signal.Data.getConversationMessageStats({
|
||||
conversationId,
|
||||
isGroup: isGroup(this.attributes),
|
||||
ourUuid,
|
||||
});
|
||||
|
||||
|
|
|
@ -2542,9 +2542,12 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
}
|
||||
|
||||
const conversationTimestamp = conversation.get('timestamp');
|
||||
const isGroupStoryReply =
|
||||
isGroup(conversation.attributes) && message.get('storyId');
|
||||
if (
|
||||
!conversationTimestamp ||
|
||||
message.get('sent_at') > conversationTimestamp
|
||||
!isGroupStoryReply &&
|
||||
(!conversationTimestamp ||
|
||||
message.get('sent_at') > conversationTimestamp)
|
||||
) {
|
||||
conversation.set({
|
||||
lastMessage: message.getNotificationText(),
|
||||
|
@ -2626,7 +2629,10 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
const isFirstRun = false;
|
||||
await this.modifyTargetMessage(conversation, isFirstRun);
|
||||
|
||||
if (isMessageUnread(this.attributes)) {
|
||||
const isGroupStoryReply =
|
||||
isGroup(conversation.attributes) && this.get('storyId');
|
||||
|
||||
if (isMessageUnread(this.attributes) && !isGroupStoryReply) {
|
||||
await conversation.notify(this);
|
||||
}
|
||||
|
||||
|
@ -2722,6 +2728,9 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
|
||||
const viewSyncs = ViewSyncs.getSingleton().forMessage(message);
|
||||
|
||||
const isGroupStoryReply =
|
||||
isGroup(conversation.attributes) && message.get('storyId');
|
||||
|
||||
if (readSyncs.length !== 0 || viewSyncs.length !== 0) {
|
||||
const markReadAt = Math.min(
|
||||
Date.now(),
|
||||
|
@ -2758,7 +2767,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
this.pendingMarkRead ?? Date.now(),
|
||||
markReadAt
|
||||
);
|
||||
} else if (isFirstRun) {
|
||||
} else if (isFirstRun && !isGroupStoryReply) {
|
||||
conversation.set({
|
||||
unreadCount: (conversation.get('unreadCount') || 0) + 1,
|
||||
isArchived: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue