Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3519473
D9048.id30655.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
D9048.id30655.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
@@ -7,7 +7,6 @@
currentAsOfSelector,
} from './keyserver-selectors.js';
import { currentCalendarQuery } from './nav-selectors.js';
-import { serverEntryInfo } from '../shared/entry-utils.js';
import { stateSyncSpecs } from '../shared/state-sync/state-sync-specs.js';
import threadWatcher from '../shared/thread-watcher.js';
import type { SignedIdentityKeysBlob } from '../types/crypto-types.js';
@@ -28,7 +27,7 @@
import { type CurrentUserInfo, type UserInfos } from '../types/user-types.js';
import { getConfig } from '../utils/config.js';
import { minimumOneTimeKeysRequired } from '../utils/crypto-utils.js';
-import { hash } from '../utils/objects.js';
+import { hash, values } from '../utils/objects.js';
const queuedReports: (
state: AppState,
@@ -109,32 +108,24 @@
: currentUserInfo,
};
+ const specPerInnerHashKey = Object.fromEntries(
+ values(stateSyncSpecs)
+ .filter(spec => spec.innerHashSpec?.hashKey)
+ .map(spec => [spec.innerHashSpec?.hashKey, spec]),
+ );
const hashResults = {};
for (const key in serverRequest.hashesToCheck) {
const expectedHashValue = serverRequest.hashesToCheck[key];
let hashValue;
if (convertedInfos[key]) {
hashValue = hash(convertedInfos[key]);
- } else if (key.startsWith('threadInfo|')) {
- const [, threadID] = key.split('|');
- hashValue = hash(
- convertedInfos[stateSyncSpecs.threads.hashKey][threadID],
- );
- } else if (key.startsWith('entryInfo|')) {
- const [, entryID] = key.split('|');
- 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(
- convertedInfos[stateSyncSpecs.users.hashKey][userID],
- );
} else {
- continue;
+ const [keyPrefix, id] = key.split('|');
+ const innerSpec = specPerInnerHashKey[keyPrefix];
+ if (!innerSpec || !id) {
+ continue;
+ }
+ hashValue = hash(convertedInfos[innerSpec.hashKey][id]);
}
hashResults[key] = expectedHashValue === hashValue;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 10:14 PM (19 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2695717
Default Alt Text
D9048.id30655.diff (2 KB)
Attached To
Mode
D9048: [lib] Use specs to determine hash value for inner infos
Attached
Detach File
Event Timeline
Log In to Comment