A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(app): drop the reply when its target message is deleted (#3237)
Hampusd87e31efafbf
diff --git a/fluxer_app/src/features/messaging/commands/MessageCommands.tsx b/fluxer_app/src/features/messaging/commands/MessageCommands.tsxindex 36268f98c..7870ee79b 100644--- a/fluxer_app/src/features/messaging/commands/MessageCommands.tsx+++ b/fluxer_app/src/features/messaging/commands/MessageCommands.tsx@@ -926,6 +926,7 @@ export async function crosspost(i18n: I18n, channelId: string, messageId: stringexport 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 {diff --git a/fluxer_app/src/features/messaging/events/MessageDelete.ts b/fluxer_app/src/features/messaging/events/MessageDelete.tsindex a03fded82..ea7561863 100644--- a/fluxer_app/src/features/messaging/events/MessageDelete.ts+++ b/fluxer_app/src/features/messaging/events/MessageDelete.ts@@ -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: GatewaChannelPins.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});diff --git a/fluxer_app/src/features/messaging/events/MessageDeleteBulk.ts b/fluxer_app/src/features/messaging/events/MessageDeleteBulk.tsindex 4ea189466..d58497589 100644--- a/fluxer_app/src/features/messaging/events/MessageDeleteBulk.ts+++ b/fluxer_app/src/features/messaging/events/MessageDeleteBulk.ts@@ -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});}diff --git a/fluxer_app/src/features/messaging/state/MessageReply.ts b/fluxer_app/src/features/messaging/state/MessageReply.tsindex 99f6a1da7..6b7045ce7 100644--- a/fluxer_app/src/features/messaging/state/MessageReply.ts+++ b/fluxer_app/src/features/messaging/state/MessageReply.ts@@ -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;}