Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32140588
D15442.1765029560.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D15442.1765029560.diff
View Options
diff --git a/lib/shared/farcaster/farcaster-hooks.js b/lib/shared/farcaster/farcaster-hooks.js
--- a/lib/shared/farcaster/farcaster-hooks.js
+++ b/lib/shared/farcaster/farcaster-hooks.js
@@ -38,6 +38,7 @@
import type { GetCommFCUsersForFIDs } from '../../hooks/user-identities-hooks.js';
import { isLoggedIn } from '../../selectors/user-selectors.js';
import { useTunnelbroker } from '../../tunnelbroker/tunnelbroker-context.js';
+import { messageTypes } from '../../types/message-types-enum.js';
import type { RawMessageInfo } from '../../types/message-types.js';
import {
messageTruncationStatus,
@@ -1197,6 +1198,28 @@
const currentlyFetchedConversations = React.useRef<Set<string>>(new Set());
const { addLog } = useDebugLogs();
+ const fetchConversation = React.useCallback(
+ async (farcasterMessage: FarcasterMessage, withMessages: boolean) => {
+ currentlyFetchedConversations.current.add(
+ farcasterMessage.conversationId,
+ );
+ const updates = new BatchedUpdates();
+ await fetchConversationWithMessages(
+ farcasterMessage.conversationId,
+ withMessages ? Number.POSITIVE_INFINITY : 0,
+ updates,
+ );
+ dispatch({
+ type: processFarcasterOpsActionType,
+ payload: updates.getReduxPayload(),
+ });
+ currentlyFetchedConversations.current.delete(
+ farcasterMessage.conversationId,
+ );
+ },
+ [dispatch, fetchConversationWithMessages],
+ );
+
return React.useCallback(
async (farcasterMessage: FarcasterMessage) => {
const threadID = farcasterThreadIDFromConversationID(
@@ -1209,22 +1232,7 @@
farcasterMessage.conversationId,
)
) {
- currentlyFetchedConversations.current.add(
- farcasterMessage.conversationId,
- );
- const updates = new BatchedUpdates();
- await fetchConversationWithMessages(
- farcasterMessage.conversationId,
- Number.POSITIVE_INFINITY,
- updates,
- );
- dispatch({
- type: processFarcasterOpsActionType,
- payload: updates.getReduxPayload(),
- });
- currentlyFetchedConversations.current.delete(
- farcasterMessage.conversationId,
- );
+ await fetchConversation(farcasterMessage, true);
return;
}
@@ -1250,6 +1258,19 @@
);
}
+ const isMembershipAddition = rawMessageInfos.some(
+ msg =>
+ msg.type === messageTypes.ADD_MEMBERS ||
+ msg.type === messageTypes.REMOVE_MEMBERS ||
+ msg.type === messageTypes.CHANGE_ROLE ||
+ msg.type === messageTypes.LEAVE_THREAD ||
+ msg.type === messageTypes.JOIN_THREAD,
+ );
+
+ if (isMembershipAddition) {
+ await fetchConversation(farcasterMessage, false);
+ }
+
const userIDs = userFIDs.map(fid => userIDFromFID(`${fid}`));
const updates: Array<ClientUpdateInfo> = [];
@@ -1275,7 +1296,7 @@
[
addLog,
dispatch,
- fetchConversationWithMessages,
+ fetchConversation,
fetchMessage,
fetchUsersByFIDs,
threadInfos,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 6, 1:59 PM (19 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5838299
Default Alt Text
D15442.1765029560.diff (3 KB)
Attached To
Mode
D15442: [lib] fetch conversation when receiving message about membership change
Attached
Detach File
Event Timeline
Log In to Comment