diff --git a/lib/hooks/input-state-container-hooks.js b/lib/hooks/input-state-container-hooks.js --- a/lib/hooks/input-state-container-hooks.js +++ b/lib/hooks/input-state-container-hooks.js @@ -30,6 +30,7 @@ threadInfo: ThreadInfo, parentThreadInfo: ?ThreadInfo, sidebarCreation: boolean, + threadCreation: boolean, ) => Promise { const sendKeyserverTextMessage = useSendTextMessage(); const sendComposableDMOperation = useSendComposableDMOperation(); @@ -47,6 +48,7 @@ threadInfo: ThreadInfo, parentThreadInfo: ?ThreadInfo, sidebarCreation: boolean, + threadCreation: boolean, ) => { invariant(viewerID, 'Viewer ID should be present'); return threadSpecs[threadInfo.type].protocol().sendTextMessage( @@ -55,6 +57,7 @@ threadInfo, parentThreadInfo, sidebarCreation, + threadCreation, }, { sendKeyserverTextMessage, @@ -85,6 +88,7 @@ messageInfo: RawMultimediaMessageInfo, sidebarCreation: boolean, isLegacy: boolean, + threadCreation: boolean, ) => Promise { const sendMultimediaMessage = useSendMultimediaMessage(); const legacySendMultimediaMessage = useLegacySendMultimediaMessage(); @@ -106,6 +110,7 @@ messageInfo: RawMultimediaMessageInfo, sidebarCreation: boolean, isLegacy: boolean, + threadCreation: boolean, ) => { const threadInfo = rawThreadInfos[messageInfo.threadID]; invariant(viewerID, 'Viewer ID should be present'); @@ -115,6 +120,7 @@ sidebarCreation, isLegacy, threadInfo, + threadCreation, }, { sendKeyserverMultimediaMessage: sendMultimediaMessage, diff --git a/lib/shared/threads/protocols/farcaster-thread-protocol.js b/lib/shared/threads/protocols/farcaster-thread-protocol.js --- a/lib/shared/threads/protocols/farcaster-thread-protocol.js +++ b/lib/shared/threads/protocols/farcaster-thread-protocol.js @@ -119,6 +119,7 @@ sendFarcasterTextMessage, rawThreadInfos, farcasterFetchConversation, + threadCreation, }: { threadInfo: ThreadInfo | RawThreadInfo, viewerID: string, @@ -129,6 +130,7 @@ farcasterFetchConversation: ( conversationID: string, ) => Promise, + threadCreation: boolean, }) { const time = Date.now(); @@ -164,7 +166,7 @@ if ( threadInfo.type === farcasterThreadTypes.FARCASTER_PERSONAL && - !rawThreadInfos[threadInfo.id] + (!rawThreadInfos[threadInfo.id] || threadCreation) ) { await farcasterFetchConversation( conversationIDFromFarcasterThreadID(threadInfo.id), @@ -185,7 +187,7 @@ farcasterFetchConversation, rawThreadInfos, } = utils; - const { messageInfo, threadInfo } = message; + const { messageInfo, threadInfo, threadCreation } = message; const { localID } = messageInfo; invariant( localID !== null && localID !== undefined, @@ -200,6 +202,7 @@ sendFarcasterTextMessage, rawThreadInfos, farcasterFetchConversation, + threadCreation, }); return { @@ -214,7 +217,7 @@ message: ProtocolSendMultimediaMessageInput, utils: SendMultimediaMessageUtils, ): Promise => { - const { messageInfo, threadInfo } = message; + const { messageInfo, threadInfo, threadCreation } = message; const { sendFarcasterTextMessage, viewerID, @@ -246,6 +249,7 @@ sendFarcasterTextMessage, rawThreadInfos, farcasterFetchConversation, + threadCreation, }); return { diff --git a/lib/shared/threads/thread-spec.js b/lib/shared/threads/thread-spec.js --- a/lib/shared/threads/thread-spec.js +++ b/lib/shared/threads/thread-spec.js @@ -124,6 +124,7 @@ +threadInfo: ThreadInfo, +parentThreadInfo: ?ThreadInfo, +sidebarCreation: boolean, + +threadCreation: boolean, }; export type SendTextMessageUtils = { +sendKeyserverTextMessage: SendTextMessageInput => Promise, @@ -143,6 +144,7 @@ +sidebarCreation: boolean, +isLegacy: boolean, +threadInfo: RawThreadInfo, + +threadCreation: boolean, }; export type SendMultimediaMessageUtils = { +sendKeyserverMultimediaMessage: SendMultimediaMessageInput => Promise, diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js --- a/native/input/input-state-container.react.js +++ b/native/input/input-state-container.react.js @@ -157,12 +157,14 @@ messageInfo: RawMultimediaMessageInfo, sidebarCreation: boolean, isLegacy: boolean, + threadCreation: boolean, ) => Promise, +sendTextMessage: ( messageInfo: RawTextMessageInfo, threadInfo: ThreadInfo, parentThreadInfo: ?ThreadInfo, sidebarCreation: boolean, + threadCreation: boolean, ) => Promise, +newThinThread: ( request: ClientNewThinThreadRequest, @@ -329,7 +331,7 @@ if (!threadIsPending(messageInfo.threadID)) { void this.props.dispatchActionPromise( sendMultimediaMessageActionTypes, - this.sendMultimediaMessageAction(messageInfo), + this.sendMultimediaMessageAction(messageInfo, false), undefined, messageInfo, ); @@ -384,7 +386,7 @@ }; void this.props.dispatchActionPromise( sendMultimediaMessageActionTypes, - this.sendMultimediaMessageAction(newMessageInfo), + this.sendMultimediaMessageAction(newMessageInfo, true), undefined, newMessageInfo, ); @@ -392,6 +394,7 @@ async sendMultimediaMessageAction( messageInfo: RawMultimediaMessageInfo, + threadCreation: boolean, ): Promise { const { localID, threadID } = messageInfo; invariant( @@ -405,6 +408,7 @@ messageInfo, sidebarCreation, false, + threadCreation, ); this.pendingSidebarCreationMessageLocalIDs.delete(localID); return result; @@ -496,6 +500,7 @@ messageInfo, inputThreadInfo, parentThreadInfo, + false, ), undefined, messageInfo, @@ -564,6 +569,7 @@ newMessageInfo, newThreadInfo, parentThreadInfo, + true, ), undefined, newMessageInfo, @@ -606,6 +612,7 @@ messageInfo: RawTextMessageInfo, threadInfo: ThreadInfo, parentThreadInfo: ?ThreadInfo, + threadCreation: boolean, ): Promise { const { localID } = messageInfo; invariant( @@ -621,6 +628,7 @@ threadInfo, parentThreadInfo, sidebarCreation, + threadCreation, ); this.pendingSidebarCreationMessageLocalIDs.delete(localID); return result; diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -147,12 +147,14 @@ messageInfo: RawMultimediaMessageInfo, sidebarCreation: boolean, isLegacy: boolean, + threadCreation: boolean, ) => Promise, +sendTextMessage: ( messageInfo: RawTextMessageInfo, threadInfo: ThreadInfo, parentThreadInfo: ?ThreadInfo, sidebarCreation: boolean, + threadCreation: boolean, ) => Promise, +newThinThread: ( request: ClientNewThinThreadRequest, @@ -443,7 +445,7 @@ if (!threadIsPending(messageInfo.threadID)) { void this.props.dispatchActionPromise( sendMultimediaMessageActionTypes, - this.sendMultimediaMessageAction(messageInfo), + this.sendMultimediaMessageAction(messageInfo, false), undefined, messageInfo, ); @@ -518,7 +520,7 @@ void this.props.dispatchActionPromise( sendMultimediaMessageActionTypes, - this.sendMultimediaMessageAction(newMessageInfo), + this.sendMultimediaMessageAction(newMessageInfo, true), undefined, newMessageInfo, ); @@ -526,6 +528,7 @@ async sendMultimediaMessageAction( messageInfo: RawMultimediaMessageInfo, + threadCreation: boolean, ): Promise { const { localID, threadID } = messageInfo; invariant( @@ -539,6 +542,7 @@ messageInfo, sidebarCreation, true, + threadCreation, ); this.pendingSidebarCreationMessageLocalIDs.delete(localID); this.setState(prevState => { @@ -1327,6 +1331,7 @@ messageInfo, inputThreadInfo, parentThreadInfo, + false, ), undefined, messageInfo, @@ -1394,6 +1399,7 @@ newMessageInfo, newThreadInfo, parentThreadInfo, + true, ), undefined, newMessageInfo, @@ -1404,6 +1410,7 @@ messageInfo: RawTextMessageInfo, threadInfo: ThreadInfo, parentThreadInfo: ?ThreadInfo, + threadCreation: boolean, ): Promise { const { localID } = messageInfo; invariant( @@ -1419,6 +1426,7 @@ threadInfo, parentThreadInfo, sidebarCreation, + threadCreation, ); this.pendingSidebarCreationMessageLocalIDs.delete(localID); return result;