Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3275802
D9031.id30766.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D9031.id30766.diff
View Options
diff --git a/lib/selectors/socket-selectors.js b/lib/selectors/socket-selectors.js
--- a/lib/selectors/socket-selectors.js
+++ b/lib/selectors/socket-selectors.js
@@ -88,53 +88,51 @@
} else if (serverRequest.type === serverRequestTypes.CHECK_STATE) {
const query = calendarQuery(calendarActive);
- const convertedEntryInfos =
- stateSyncSpecs.entries.convertClientToServerInfos(
- entryInfos,
- query,
- );
-
- const convertedThreadInfos =
- stateSyncSpecs.threads.convertClientToServerInfos(
- threadInfos,
- query,
- );
-
- const convertedUserInfos =
- stateSyncSpecs.users.convertClientToServerInfos(userInfos, query);
-
- const convertedCurrentUserInfo = currentUserInfo
- ? stateSyncSpecs.currentUser.convertClientToServerInfos(
- currentUserInfo,
+ const convertedInfos = {
+ [stateSyncSpecs.entries.hashKey]:
+ stateSyncSpecs.entries.convertClientToServerInfos(
+ entryInfos,
+ query,
+ ),
+ [stateSyncSpecs.threads.hashKey]:
+ stateSyncSpecs.threads.convertClientToServerInfos(
+ threadInfos,
query,
- )
- : currentUserInfo;
+ ),
+ [stateSyncSpecs.users.hashKey]:
+ stateSyncSpecs.users.convertClientToServerInfos(userInfos, query),
+ [stateSyncSpecs.currentUser.hashKey]: currentUserInfo
+ ? stateSyncSpecs.currentUser.convertClientToServerInfos(
+ currentUserInfo,
+ query,
+ )
+ : currentUserInfo,
+ };
const hashResults = {};
for (const key in serverRequest.hashesToCheck) {
const expectedHashValue = serverRequest.hashesToCheck[key];
let hashValue;
- if (key === 'threadInfos') {
- hashValue = hash(convertedThreadInfos);
- } else if (key === 'entryInfos') {
- hashValue = hash(convertedEntryInfos);
- } else if (key === 'userInfos') {
- hashValue = hash(convertedUserInfos);
- } else if (key === 'currentUserInfo') {
- hashValue = hash(convertedCurrentUserInfo);
+ if (convertedInfos[key]) {
+ hashValue = hash(convertedInfos[key]);
} else if (key.startsWith('threadInfo|')) {
const [, threadID] = key.split('|');
- hashValue = hash(convertedThreadInfos[threadID]);
+ hashValue = hash(
+ convertedInfos[stateSyncSpecs.threads.hashKey][threadID],
+ );
} else if (key.startsWith('entryInfo|')) {
const [, entryID] = key.split('|');
- let rawEntryInfo = convertedEntryInfos[entryID];
+ let rawEntryInfo =
+ convertedInfos[stateSyncSpecs.entries.hashKey][entryID];
if (rawEntryInfo) {
rawEntryInfo = serverEntryInfo(rawEntryInfo);
}
hashValue = hash(rawEntryInfo);
} else if (key.startsWith('userInfo|')) {
const [, userID] = key.split('|');
- hashValue = hash(convertedUserInfos[userID]);
+ hashValue = hash(
+ convertedInfos[stateSyncSpecs.users.hashKey][userID],
+ );
} else {
continue;
}
@@ -143,7 +141,9 @@
const { failUnmentioned } = serverRequest;
if (failUnmentioned && failUnmentioned.threadInfos) {
- for (const threadID in convertedThreadInfos) {
+ for (const threadID in convertedInfos[
+ stateSyncSpecs.threads.hashKey
+ ]) {
const key = `threadInfo|${threadID}`;
const hashResult = hashResults[key];
if (hashResult === null || hashResult === undefined) {
@@ -152,7 +152,9 @@
}
}
if (failUnmentioned && failUnmentioned.entryInfos) {
- for (const entryID in convertedEntryInfos) {
+ for (const entryID in convertedInfos[
+ stateSyncSpecs.entries.hashKey
+ ]) {
const key = `entryInfo|${entryID}`;
const hashResult = hashResults[key];
if (hashResult === null || hashResult === undefined) {
@@ -161,7 +163,7 @@
}
}
if (failUnmentioned && failUnmentioned.userInfos) {
- for (const userID in convertedUserInfos) {
+ for (const userID in convertedInfos[stateSyncSpecs.users.hashKey]) {
const key = `userInfo|${userID}`;
const hashResult = hashResults[key];
if (hashResult === null || hashResult === undefined) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 7:12 AM (20 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2517617
Default Alt Text
D9031.id30766.diff (4 KB)
Attached To
Mode
D9031: [lib] Use specs to determine hash value for top-level infos
Attached
Detach File
Event Timeline
Log In to Comment