diff --git a/lib/types/sqlite-types.js b/lib/types/sqlite-types.js --- a/lib/types/sqlite-types.js +++ b/lib/types/sqlite-types.js @@ -1,5 +1,7 @@ // @flow +import type { StoreOperations } from './store-ops-types.js'; + export type ReceivedMessageToDevice = { +messageID: string, +senderDeviceID: string, @@ -15,4 +17,9 @@ +removeReceivedMessagesToDevice: ( ids: $ReadOnlyArray, ) => Promise, + + +processDBStoreOperations: ( + operations: StoreOperations, + userID?: ?string, + ) => Promise, }; diff --git a/lib/utils/__mocks__/config.js b/lib/utils/__mocks__/config.js --- a/lib/utils/__mocks__/config.js +++ b/lib/utils/__mocks__/config.js @@ -29,6 +29,7 @@ sqliteAPI: { getAllReceivedMessageToDevice: jest.fn(), removeReceivedMessagesToDevice: jest.fn(), + processDBStoreOperations: jest.fn(), }, }); diff --git a/native/database/sqlite-api.js b/native/database/sqlite-api.js --- a/native/database/sqlite-api.js +++ b/native/database/sqlite-api.js @@ -3,6 +3,7 @@ import type { SQLiteAPI } from 'lib/types/sqlite-types.js'; import { commCoreModule } from '../native-modules.js'; +import { processDBStoreOperations } from '../redux/redux-utils.js'; const sqliteAPI: SQLiteAPI = { // read operations @@ -10,6 +11,8 @@ // write operations removeReceivedMessagesToDevice: commCoreModule.removeReceivedMessagesToDevice, + + processDBStoreOperations, }; export { sqliteAPI }; diff --git a/web/database/sqlite-api.js b/web/database/sqlite-api.js --- a/web/database/sqlite-api.js +++ b/web/database/sqlite-api.js @@ -6,6 +6,7 @@ } from 'lib/types/sqlite-types.js'; import { getCommSharedWorker } from '../shared-worker/shared-worker-provider.js'; +import { processDBStoreOperations } from '../shared-worker/utils/store.js'; import { workerRequestMessageTypes } from '../types/worker-types.js'; const sqliteAPI: SQLiteAPI = { @@ -31,6 +32,8 @@ ids, }); }, + + processDBStoreOperations, }; export { sqliteAPI }; diff --git a/web/shared-worker/utils/store.js b/web/shared-worker/utils/store.js --- a/web/shared-worker/utils/store.js +++ b/web/shared-worker/utils/store.js @@ -140,7 +140,7 @@ async function processDBStoreOperations( storeOperations: StoreOperations, - userID: null | string, + userID?: ?string, ): Promise { const { draftStoreOperations,