Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3280531
D10787.id36910.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D10787.id36910.diff
View Options
diff --git a/lib/reducers/keyserver-reducer.js b/lib/reducers/keyserver-reducer.js
--- a/lib/reducers/keyserver-reducer.js
+++ b/lib/reducers/keyserver-reducer.js
@@ -2,6 +2,7 @@
import { unsupervisedBackgroundActionType } from './lifecycle-state-reducer.js';
import { updateActivityActionTypes } from '../actions/activity-actions.js';
+import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
import {
updateLastCommunicatedPlatformDetailsActionType,
setDeviceTokenActionTypes,
@@ -35,7 +36,10 @@
type KeyserverStoreOperation,
} from '../ops/keyserver-store-ops.js';
import { queueActivityUpdatesActionType } from '../types/activity-types.js';
-import type { KeyserverStore } from '../types/keyserver-types.js';
+import type {
+ KeyserverInfos,
+ KeyserverStore,
+} from '../types/keyserver-types.js';
import type { BaseAction } from '../types/redux-types.js';
import {
fullStateSyncActionType,
@@ -44,14 +48,42 @@
import { updateTypes } from '../types/update-types-enum.js';
import { processUpdatesActionType } from '../types/update-types.js';
import { getConfig } from '../utils/config.js';
+import { getMessageForException } from '../utils/errors.js';
+import { assertObjectsAreEqual } from '../utils/objects.js';
import { setURLPrefix } from '../utils/url-utils.js';
import { ashoatKeyserverID } from '../utils/validation-utils.js';
+function assertKeyserverStoresAreEqual(
+ processedKeyserverStore: KeyserverInfos,
+ expectedKeyserverStore: KeyserverInfos,
+ location: string,
+ onStateDifference?: (message: string) => mixed,
+) {
+ try {
+ assertObjectsAreEqual(
+ processedKeyserverStore,
+ expectedKeyserverStore,
+ `KeyserverInfos - ${location}`,
+ );
+ } catch (e) {
+ console.log(
+ 'Error processing KeyserverStore ops',
+ processedKeyserverStore,
+ expectedKeyserverStore,
+ );
+ const message = `Error processing KeyserverStore ops ${
+ getMessageForException(e) ?? '{no exception message}'
+ }`;
+ onStateDifference?.(message);
+ }
+}
+
const { processStoreOperations: processStoreOps } = keyserverStoreOpsHandlers;
export default function reduceKeyserverStore(
state: KeyserverStore,
action: BaseAction,
+ onStateDifference?: (message: string) => mixed,
): {
keyserverStore: KeyserverStore,
keyserverStoreOperations: $ReadOnlyArray<KeyserverStoreOperation>,
@@ -583,6 +615,19 @@
keyserverStore: processStoreOps(state, [operation]),
keyserverStoreOperations: [operation],
};
+ } else if (action.type === setClientDBStoreActionType) {
+ // Once the functionality is confirmed to work correctly,
+ // we will proceed with returning keyserverInfos from the payload.
+ assertKeyserverStoresAreEqual(
+ action.payload.keyserverInfos ?? {},
+ state.keyserverInfos,
+ action.type,
+ onStateDifference,
+ );
+ return {
+ keyserverStore: state,
+ keyserverStoreOperations: [],
+ };
}
return {
diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js
--- a/lib/reducers/master-reducer.js
+++ b/lib/reducers/master-reducer.js
@@ -84,6 +84,7 @@
let { keyserverStore, keyserverStoreOperations } = reduceKeyserverStore(
state.keyserverStore,
action,
+ onStateDifferenceForStaff,
);
if (
diff --git a/lib/reducers/message-reducer.test.js b/lib/reducers/message-reducer.test.js
--- a/lib/reducers/message-reducer.test.js
+++ b/lib/reducers/message-reducer.test.js
@@ -291,6 +291,7 @@
messages: clientDBMessages,
reports: [],
users: {},
+ keyserverInfos: {},
},
},
{
diff --git a/lib/types/store-ops-types.js b/lib/types/store-ops-types.js
--- a/lib/types/store-ops-types.js
+++ b/lib/types/store-ops-types.js
@@ -5,6 +5,7 @@
ClientDBDraftStoreOperation,
ClientDBDraftInfo,
} from './draft-types.js';
+import type { KeyserverInfos } from './keyserver-types.js';
import type {
ClientDBMessageInfo,
ClientDBThreadMessageInfo,
@@ -70,4 +71,5 @@
+messageStoreThreads: ?$ReadOnlyArray<ClientDBThreadMessageInfo>,
+reports: ?$ReadOnlyArray<ClientReportCreationRequest>,
+users: ?UserInfos,
+ +keyserverInfos: ?KeyserverInfos,
};
diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js
--- a/native/data/sqlite-data-handler.js
+++ b/native/data/sqlite-data-handler.js
@@ -7,6 +7,7 @@
import { MediaCacheContext } from 'lib/components/media-cache-provider.react.js';
import { useStaffContext } from 'lib/components/staff-provider.react.js';
import { resolveKeyserverSessionInvalidation } from 'lib/keyserver-conn/recovery-utils.js';
+import { keyserverStoreOpsHandlers } from 'lib/ops/keyserver-store-ops.js';
import { reportStoreOpsHandlers } from 'lib/ops/report-store-ops.js';
import { threadStoreOpsHandlers } from 'lib/ops/thread-store-ops.js';
import { userStoreOpsHandlers } from 'lib/ops/user-store-ops.js';
@@ -177,12 +178,15 @@
messageStoreThreads,
reports,
users,
+ keyservers,
} = await commCoreModule.getClientDBStore();
const threadInfosFromDB =
threadStoreOpsHandlers.translateClientDBData(threads);
- const reportsFromDb =
+ const reportsFromDB =
reportStoreOpsHandlers.translateClientDBData(reports);
- const usersFromDb = userStoreOpsHandlers.translateClientDBData(users);
+ const usersFromDB = userStoreOpsHandlers.translateClientDBData(users);
+ const keyserverInfosFromDB =
+ keyserverStoreOpsHandlers.translateClientDBData(keyservers);
dispatch({
type: setClientDBStoreActionType,
@@ -192,8 +196,9 @@
threadStore: { threadInfos: threadInfosFromDB },
currentUserID: currentLoggedInUserID,
messageStoreThreads,
- reports: reportsFromDb,
- users: usersFromDb,
+ reports: reportsFromDB,
+ users: usersFromDB,
+ keyserverInfos: keyserverInfosFromDB,
},
});
} catch (setStoreException) {
diff --git a/web/database/utils/store.js b/web/database/utils/store.js
--- a/web/database/utils/store.js
+++ b/web/database/utils/store.js
@@ -22,6 +22,7 @@
messageStoreThreads: null,
reports: null,
users: null,
+ keyserverInfos: null,
};
const data = await databaseModule.schedule({
type: workerRequestMessageTypes.GET_CLIENT_STORE,
@@ -48,6 +49,14 @@
},
};
}
+ if (data?.store?.keyservers) {
+ result = {
+ ...result,
+ keyserverInfos: keyserverStoreOpsHandlers.translateClientDBData(
+ data.store.keyservers,
+ ),
+ };
+ }
return result;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 9:14 AM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2517839
Default Alt Text
D10787.id36910.diff (6 KB)
Attached To
Mode
D10787: [web][native] read keyservers from SQLite on app start
Attached
Detach File
Event Timeline
Log In to Comment