Page MenuHomePhabricator

D9318.id31615.diff
No OneTemporary

D9318.id31615.diff

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

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)

Event Timeline