Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32179210
D15217.1765072646.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D15217.1765072646.diff
View Options
diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js
--- a/lib/reducers/message-reducer.js
+++ b/lib/reducers/message-reducer.js
@@ -67,6 +67,7 @@
createReplaceMessageStoreThreadsOperations,
} from '../ops/message-store-ops.js';
import { pendingToRealizedThreadIDsSelector } from '../selectors/thread-selectors.js';
+import { processFarcasterOpsActionType } from '../shared/farcaster/farcaster-actions.js';
import {
localIDPrefix,
messageID,
@@ -1940,6 +1941,26 @@
localOperation,
]),
};
+ } else if (action.type === processFarcasterOpsActionType) {
+ const { rawMessageInfos, updateInfos } = action.payload;
+
+ const messagesResult = mergeUpdatesWithMessageInfos(
+ rawMessageInfos,
+ updateInfos,
+ );
+
+ const { messageStoreOperations, messageStore: newMessageStore } =
+ mergeNewMessages(
+ messageStore,
+ messagesResult.rawMessageInfos,
+ messagesResult.truncationStatuses,
+ newThreadInfos,
+ );
+
+ return {
+ messageStoreOperations,
+ messageStore: newMessageStore,
+ };
}
return { messageStoreOperations: [], messageStore };
}
diff --git a/lib/reducers/thread-reducer.js b/lib/reducers/thread-reducer.js
--- a/lib/reducers/thread-reducer.js
+++ b/lib/reducers/thread-reducer.js
@@ -40,6 +40,7 @@
threadStoreOpsHandlers,
} from '../ops/thread-store-ops.js';
import { getThreadUpdatesForNewMessages } from '../shared/dm-ops/dm-op-utils.js';
+import { processFarcasterOpsActionType } from '../shared/farcaster/farcaster-actions.js';
import { stateSyncSpecs } from '../shared/state-sync/state-sync-specs.js';
import { updateSpecs } from '../shared/updates/update-specs.js';
import { processDMOpsActionType } from '../types/dm-ops.js';
@@ -586,6 +587,23 @@
...threadStoreOperationsWithNewMessagesUpdates,
],
};
+ } else if (action.type === processFarcasterOpsActionType) {
+ const { updateInfos } = action.payload;
+ if (updateInfos.length === 0) {
+ return {
+ threadStore: state,
+ newThreadInconsistencies: [],
+ threadStoreOperations: [],
+ };
+ }
+ const { threadStoreOperations, updatedThreadStore } =
+ generateOpsAndProcessThreadUpdates(state, updateInfos);
+
+ return {
+ threadStore: updatedThreadStore,
+ newThreadInconsistencies: [],
+ threadStoreOperations,
+ };
}
return {
threadStore: state,
diff --git a/lib/selectors/thread-selectors.js b/lib/selectors/thread-selectors.js
--- a/lib/selectors/thread-selectors.js
+++ b/lib/selectors/thread-selectors.js
@@ -270,7 +270,7 @@
(state: BaseAppState<>) => state.threadStore.threadInfos,
(threadInfos: RawThreadInfos): { +[keyserverID: string]: number } => {
const thinThreadInfosList = values(threadInfos).filter(
- threadInfo => !threadInfo.thick,
+ threadInfo => !threadInfo.thick && !threadInfo.farcaster,
);
const keyserverToThreads = _groupBy(threadInfo =>
diff --git a/lib/shared/farcaster/farcaster-actions.js b/lib/shared/farcaster/farcaster-actions.js
new file mode 100644
--- /dev/null
+++ b/lib/shared/farcaster/farcaster-actions.js
@@ -0,0 +1,11 @@
+// @flow
+
+import type { RawMessageInfo } from '../../types/message-types.js';
+import type { ClientUpdateInfo } from '../../types/update-types.js';
+
+export const processFarcasterOpsActionType = 'PROCESS_FARCASTER_OPS';
+
+export type ProcessFarcasterOpsPayload = {
+ +rawMessageInfos: $ReadOnlyArray<RawMessageInfo>,
+ +updateInfos: $ReadOnlyArray<ClientUpdateInfo>,
+};
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
@@ -1,7 +1,9 @@
// @flow
import * as React from 'react';
+import uuid from 'uuid';
+import { processFarcasterOpsActionType } from './farcaster-actions.js';
import {
type FetchFarcasterConversationResult,
useFetchFarcasterConversation,
@@ -12,6 +14,10 @@
} from './farcaster-api.js';
import type { FarcasterConversation } from './farcaster-conversation-types.js';
import type { FarcasterMessage } from './farcaster-messages-types.js';
+import { messageTruncationStatus } from '../../types/message-types.js';
+import { updateTypes } from '../../types/update-types-enum.js';
+import type { ClientUpdateInfo } from '../../types/update-types.js';
+import { createFarcasterRawThreadInfo } from '../../utils/farcaster-utils.js';
import { useDispatch } from '../../utils/redux-utils.js';
import { useSendDMOperationUtils } from '../dm-ops/dm-op-utils.js';
@@ -83,7 +89,10 @@
.filter(Boolean)
.map(conversationResult => conversationResult.result.conversation);
- console.log('Farcaster conversations:', farcasterConversations);
+ console.log(
+ 'Farcaster conversations:',
+ JSON.stringify(farcasterConversations, null, 2),
+ );
const messagePromises: $ReadOnlyArray<
Promise<?FetchFarcasterMessageResult>,
@@ -104,9 +113,34 @@
.filter(Boolean)
.flatMap(messagesResult => messagesResult.result.messages);
- console.log('Farcaster messages:', farcasterMessages);
+ console.log(
+ 'Farcaster messages:',
+ JSON.stringify(farcasterMessages, null, 2),
+ );
+
+ //TODO: dispatch messages
+ const updates = farcasterConversations
+ .map(conversation => createFarcasterRawThreadInfo(conversation))
+ .map(
+ thread =>
+ ({
+ type: updateTypes.JOIN_THREAD,
+ id: uuid.v4(),
+ time: thread.creationTime,
+ threadInfo: thread,
+ rawMessageInfos: [],
+ truncationStatus: messageTruncationStatus.UNCHANGED,
+ rawEntryInfos: [],
+ }: ClientUpdateInfo),
+ );
+ dispatch({
+ type: processFarcasterOpsActionType,
+ payload: {
+ rawMessageInfos: [],
+ updateInfos: updates,
+ },
+ });
- //TODO: dispatch threads and messages
setConversations([]);
})();
}, [
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
@@ -94,11 +94,7 @@
throw new Error('createPendingThread method is not yet implemented');
},
- couldBeCreatedFromPendingThread: (): boolean => {
- throw new Error(
- 'couldBeCreatedFromPendingThread method is not yet implemented',
- );
- },
+ couldBeCreatedFromPendingThread: () => true,
canBeFrozen: (): boolean => {
throw new Error('canBeFrozen method is not yet implemented');
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -182,6 +182,7 @@
SetLateResponsePayload,
UpdateKeyserverReachabilityPayload,
} from '../keyserver-conn/keyserver-conn-types.js';
+import type { ProcessFarcasterOpsPayload } from '../shared/farcaster/farcaster-actions.js';
import type { SendMessageError } from '../utils/errors.js';
// Before making changes here, make sure to consider how the added property
@@ -1713,6 +1714,10 @@
+error: true,
+payload: Error,
+loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'PROCESS_FARCASTER_OPS',
+ +payload: ProcessFarcasterOpsPayload,
},
}>;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 1:57 AM (11 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842044
Default Alt Text
D15217.1765072646.diff (7 KB)
Attached To
Mode
D15217: [lib] Load Farcaster threads into the store
Attached
Detach File
Event Timeline
Log In to Comment