Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(channels): missing nonce for attachments (#1308)

teoa1fe1d46929b
diff --git a/js/app/packages/queries/channel/message.ts b/js/app/packages/queries/channel/message.ts
index b665208b3f..fd6a69e326 100644
--- a/js/app/packages/queries/channel/message.ts
+++ b/js/app/packages/queries/channel/message.ts
@@ -21,6 +21,20 @@ import { queryClient } from '../client';
import { channelKeys, ChannelNonceKeys } from './keys';
import { createMutationNonce, registerNonce } from '../nonce';
+/**
+ * Register nonces for both message and attachment deduplication.
+ * The server echoes the same nonce for both message and attachment WebSocket events.
+ */
+function registerMessageNonces(
+ optimisticId: string,
+ hasAttachments: boolean
+): void {
+ registerNonce(ChannelNonceKeys.MESSAGE, optimisticId);
+ if (hasAttachments) {
+ registerNonce(ChannelNonceKeys.ATTACHMENT, optimisticId);
+ }
+}
+
type WithChannelId<T> = T & { channelId: string };
type WithOptimisticId<T> = T & { optimisticId: string };
type WithSenderId<T> = T & { senderId: string };
@@ -353,8 +367,11 @@ export function useSendMessageMutation(
...withCallbacks<IdResponse, Error, SendMessageParams, SendMessageContext>(
{
onMutate: (vars) => {
- // Register nonce for deduplication when WebSocket event arrives
- registerNonce(ChannelNonceKeys.MESSAGE, vars.optimisticId);
+ // Register nonces for deduplication when WebSocket events arrive
+ registerMessageNonces(
+ vars.optimisticId,
+ vars.message.attachments.length > 0
+ );
return optimisticInsertChannelMessage({
channelId: vars.channelID,
optimisticId: vars.optimisticId,