Don't display sent stories in groups

This commit is contained in:
Fedor Indutny 2022-10-20 15:47:38 -07:00 committed by GitHub
parent 5dea03f713
commit d26c5b7db8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1363,14 +1363,16 @@ export class ConversationModel extends window.Backbone
message: MessageModel, message: MessageModel,
{ isJustSent }: { isJustSent: boolean } = { isJustSent: false } { isJustSent }: { isJustSent: boolean } = { isJustSent: false }
): Promise<void> { ): Promise<void> {
await this.beforeAddSingleMessage(); await this.beforeAddSingleMessage(message);
this.doAddSingleMessage(message, { isJustSent }); this.doAddSingleMessage(message, { isJustSent });
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.debouncedUpdateLastMessage!(); this.debouncedUpdateLastMessage!();
} }
private async beforeAddSingleMessage(): Promise<void> { private async beforeAddSingleMessage(message: MessageModel): Promise<void> {
await message.hydrateStoryContext();
if (!this.newMessageQueue) { if (!this.newMessageQueue) {
this.newMessageQueue = new PQueue({ this.newMessageQueue = new PQueue({
concurrency: 1, concurrency: 1,
@ -1402,7 +1404,12 @@ export class ConversationModel extends window.Backbone
if (isJustSent && existingConversation && !isLatestInMemory) { if (isJustSent && existingConversation && !isLatestInMemory) {
this.loadNewestMessages(undefined, undefined); this.loadNewestMessages(undefined, undefined);
} else { } else if (
// The message has to be not a story or has to be a story reply in direct
// conversation.
!isStory(message.attributes) &&
(message.get('storyId') == null || isDirectConversation(this.attributes))
) {
messagesAdded({ messagesAdded({
conversationId, conversationId,
messages: [{ ...message.attributes }], messages: [{ ...message.attributes }],
@ -4029,56 +4036,53 @@ export class ConversationModel extends window.Backbone
const renderStart = Date.now(); const renderStart = Date.now();
// Don't update the conversation with a story reply // Perform asynchronous tasks before entering the batching mode
if (storyId == null) { await this.beforeAddSingleMessage(model);
// Perform asynchronous tasks before entering the batching mode
await this.beforeAddSingleMessage();
this.isInReduxBatch = true; this.isInReduxBatch = true;
batchDispatch(() => { batchDispatch(() => {
try { try {
const { clearUnreadMetrics } = window.reduxActions.conversations; const { clearUnreadMetrics } = window.reduxActions.conversations;
clearUnreadMetrics(this.id); clearUnreadMetrics(this.id);
const enabledProfileSharing = Boolean( const enabledProfileSharing = Boolean(
mandatoryProfileSharingEnabled && !this.get('profileSharing') mandatoryProfileSharingEnabled && !this.get('profileSharing')
); );
const unarchivedConversation = Boolean(this.get('isArchived')); const unarchivedConversation = Boolean(this.get('isArchived'));
this.doAddSingleMessage(model, { isJustSent: true }); this.doAddSingleMessage(model, { isJustSent: true });
const draftProperties = dontClearDraft const draftProperties = dontClearDraft
? {} ? {}
: { : {
draft: null, draft: null,
draftTimestamp: null, draftTimestamp: null,
lastMessage: model.getNotificationText(), lastMessage: model.getNotificationText(),
lastMessageAuthor: model.getAuthorText(), lastMessageAuthor: model.getAuthorText(),
lastMessageStatus: 'sending' as const, lastMessageStatus: 'sending' as const,
}; };
this.set({ this.set({
...draftProperties, ...draftProperties,
...(enabledProfileSharing ? { profileSharing: true } : {}), ...(enabledProfileSharing ? { profileSharing: true } : {}),
...this.incrementSentMessageCount({ dry: true }), ...this.incrementSentMessageCount({ dry: true }),
active_at: now, active_at: now,
timestamp: now, timestamp: now,
...(unarchivedConversation ? { isArchived: false } : {}), ...(unarchivedConversation ? { isArchived: false } : {}),
}); });
if (enabledProfileSharing) { if (enabledProfileSharing) {
this.captureChange('enqueueMessageForSend/mandatoryProfileSharing'); this.captureChange('enqueueMessageForSend/mandatoryProfileSharing');
}
if (unarchivedConversation) {
this.captureChange('enqueueMessageForSend/unarchive');
}
extraReduxActions?.();
} finally {
this.isInReduxBatch = false;
} }
}); if (unarchivedConversation) {
} this.captureChange('enqueueMessageForSend/unarchive');
}
extraReduxActions?.();
} finally {
this.isInReduxBatch = false;
}
});
if (sticker) { if (sticker) {
await addStickerPackReference(model.id, sticker.packId); await addStickerPackReference(model.id, sticker.packId);