Don't display sent stories in groups
This commit is contained in:
parent
5dea03f713
commit
d26c5b7db8
1 changed files with 50 additions and 46 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue