fix(app): drop the reply when its target message is deleted (#3237)

This commit is contained in:
Hampus
2026-10-06 02:14:00 +02:00
committed by GitHub
parent 6618a6baf4
commit d87e31efaf
4 changed files with 18 additions and 0 deletions
@@ -926,6 +926,7 @@ export async function crosspost(i18n: I18n, channelId: string, messageId: string
export function deleteLocal(channelId: string, messageId: string): void {
logger.debug(`Deleting message ${messageId} locally in channel ${channelId}`);
Messages.handleMessageDelete({id: messageId, channelId});
MessageReply.handleMessageDelete(channelId, messageId);
}
export function revealMessage(channelId: string, messageId: string | null): void {
@@ -3,6 +3,7 @@
import ChannelPins from '@app/features/channel/state/ChannelPins';
import type {GatewayHandlerContext} from '@app/features/gateway/events/EventRouter';
import MessageReferences from '@app/features/messaging/state/MessageReferences';
import MessageReply from '@app/features/messaging/state/MessageReply';
import Messages from '@app/features/messaging/state/MessagingMessages';
import SavedMessages from '@app/features/messaging/state/SavedMessages';
import MentionFeed from '@app/features/notification/state/MentionFeed';
@@ -20,6 +21,7 @@ export function handleMessageDelete(data: MessageDeletePayload, _context: Gatewa
ChannelPins.handleMessageDelete(data.channel_id, data.id);
Messages.handleMessageDelete({channelId: data.channel_id, id: data.id});
MessageReferences.handleMessageDelete(data.channel_id, data.id);
MessageReply.handleMessageDelete(data.channel_id, data.id);
ReadStates.handleMessageDelete({channelId: data.channel_id});
MentionFeed.handleMessageDelete(data.id);
Notification.handleMessageDelete({channelId: data.channel_id});
@@ -2,6 +2,7 @@
import type {GatewayHandlerContext} from '@app/features/gateway/events/EventRouter';
import MessageReferences from '@app/features/messaging/state/MessageReferences';
import MessageReply from '@app/features/messaging/state/MessageReply';
import Messages from '@app/features/messaging/state/MessagingMessages';
import ReadStates from '@app/features/read_state/state/ReadStates';
import Notification from '@app/features/ui/state/Notification';
@@ -14,6 +15,7 @@ interface MessageDeleteBulkPayload {
export function handleMessageDeleteBulk(data: MessageDeleteBulkPayload, _context: GatewayHandlerContext): void {
Messages.handleMessageDeleteBulk({channelId: data.channel_id, ids: data.ids});
MessageReferences.handleMessageDeleteBulk(data.channel_id, data.ids);
MessageReply.handleMessageDeleteBulk(data.channel_id, data.ids);
ReadStates.handleMessageDelete({channelId: data.channel_id});
Notification.handleMessageDelete({channelId: data.channel_id});
}
@@ -56,6 +56,19 @@ class MessageReply {
delete this.replyingMessageIds[channelId];
}
handleMessageDelete(channelId: string, messageId: string): void {
if (this.replyingMessageIds[channelId]?.messageId === messageId) {
delete this.replyingMessageIds[channelId];
}
}
handleMessageDeleteBulk(channelId: string, messageIds: Array<string>): void {
const current = this.replyingMessageIds[channelId];
if (current && messageIds.includes(current.messageId)) {
delete this.replyingMessageIds[channelId];
}
}
highlightMessage(messageId: string): void {
this.highlightMessageId = messageId;
}