Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3520730
D9318.id31615.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9318.id31615.diff
View Options
diff --git a/lib/reducers/local-id-reducer.js b/lib/reducers/local-id-reducer.js
--- a/lib/reducers/local-id-reducer.js
+++ b/lib/reducers/local-id-reducer.js
@@ -17,6 +17,7 @@
numberFromLocalID,
highestLocalIDSelector,
} from '../selectors/local-id-selectors.js';
+import { updateSpecs } from '../shared/updates/update-specs.js';
import type { RawMessageInfo } from '../types/message-types.js';
import type { BaseAction } from '../types/redux-types.js';
import { rehydrateActionType } from '../types/redux-types.js';
@@ -24,7 +25,6 @@
fullStateSyncActionType,
incrementalStateSyncActionType,
} from '../types/socket-types.js';
-import { updateTypes } from '../types/update-types-enum.js';
import {
type ClientUpdateInfo,
processUpdatesActionType,
@@ -112,14 +112,8 @@
function getRawMessageInfosFromUpdates(
updates: $ReadOnlyArray<ClientUpdateInfo>,
): RawMessageInfo[] {
- const rawMessageInfos = [];
- for (const updateInfo of updates) {
- if (updateInfo.type !== updateTypes.JOIN_THREAD) {
- continue;
- }
- for (const messageInfo of updateInfo.rawMessageInfos) {
- rawMessageInfos.push(messageInfo);
- }
- }
- return rawMessageInfos;
+ return updates
+ .map(update => updateSpecs[update.type].getRawMessageInfos?.(update))
+ .filter(Boolean)
+ .flat();
}
diff --git a/lib/shared/updates/join-thread-spec.js b/lib/shared/updates/join-thread-spec.js
--- a/lib/shared/updates/join-thread-spec.js
+++ b/lib/shared/updates/join-thread-spec.js
@@ -52,4 +52,7 @@
}
return new Set([...filteredThreadIDs, update.threadInfo.id]);
},
+ getRawMessageInfos(update: ThreadJoinUpdateInfo) {
+ return update.rawMessageInfos;
+ },
});
diff --git a/lib/shared/updates/update-spec.js b/lib/shared/updates/update-spec.js
--- a/lib/shared/updates/update-spec.js
+++ b/lib/shared/updates/update-spec.js
@@ -2,6 +2,7 @@
import type { ThreadStoreOperation } from '../../ops/thread-store-ops.js';
import type { RawEntryInfo } from '../../types/entry-types.js';
+import type { RawMessageInfo } from '../../types/message-types.js';
import type { RawThreadInfos } from '../../types/thread-types.js';
import type { ClientUpdateInfo } from '../../types/update-types.js';
import type { CurrentUserInfo, UserInfos } from '../../types/user-types.js';
@@ -25,4 +26,5 @@
filteredThreadIDs: $ReadOnlySet<string>,
update: UpdateInfo,
) => $ReadOnlySet<string>,
+ +getRawMessageInfos?: (update: UpdateInfo) => $ReadOnlyArray<RawMessageInfo>,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 1:12 AM (19 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2697705
Default Alt Text
D9318.id31615.diff (2 KB)
Attached To
Mode
D9318: [lib] Move local id update reducer into specs
Attached
Detach File
Event Timeline
Log In to Comment