diff --git a/web/shared-worker/worker/shared-worker.js b/web/shared-worker/worker/shared-worker.js --- a/web/shared-worker/worker/shared-worker.js +++ b/web/shared-worker/worker/shared-worker.js @@ -238,6 +238,13 @@ type: workerResponseMessageTypes.GET_PERSIST_STORAGE_ITEM, item: sqliteQueryExecutor.getPersistStorageItem(message.key), }; + } else if ( + message.type === workerRequestMessageTypes.GET_RECEIVED_MESSAGES_TO_DEVICE + ) { + return { + type: workerResponseMessageTypes.GET_RECEIVED_MESSAGES_TO_DEVICE, + result: sqliteQueryExecutor.getAllReceivedMessageToDevice(), + }; } // write operations @@ -303,6 +310,11 @@ message.backupDataKey, message.backupLogDataKey, ); + } else if ( + message.type === + workerRequestMessageTypes.REMOVE_RECEIVED_MESSAGES_TO_DEVICE + ) { + sqliteQueryExecutor.removeReceivedMessagesToDevice(message.ids); } persistNeeded = true; diff --git a/web/types/worker-types.js b/web/types/worker-types.js --- a/web/types/worker-types.js +++ b/web/types/worker-types.js @@ -11,6 +11,7 @@ IdentityServiceClient, IdentityServiceAuthLayer, } from 'lib/types/identity-service-types.js'; +import type { ReceivedMessageToDevice } from 'lib/types/sqlite-types.js'; import type { ClientDBStore, ClientDBStoreOperations, @@ -34,6 +35,8 @@ CREATE_IDENTITY_SERVICE_CLIENT: 13, CALL_IDENTITY_CLIENT_METHOD: 14, CALL_OLM_API_METHOD: 15, + GET_RECEIVED_MESSAGES_TO_DEVICE: 16, + REMOVE_RECEIVED_MESSAGES_TO_DEVICE: 17, }); export const workerWriteRequests: $ReadOnlyArray = [ @@ -43,6 +46,7 @@ workerRequestMessageTypes.REMOVE_PERSIST_STORAGE_ITEM, workerRequestMessageTypes.BACKUP_RESTORE, workerRequestMessageTypes.INITIALIZE_CRYPTO_ACCOUNT, + workerRequestMessageTypes.REMOVE_RECEIVED_MESSAGES_TO_DEVICE, ]; export const workerOlmAPIRequests: $ReadOnlyArray = [ @@ -151,6 +155,15 @@ +args: $ReadOnlyArray, }; +export type GetReceivedMessagesToDeviceRequestMessage = { + +type: 16, +}; + +export type RemoveReceivedMessagesToDeviceRequestMessage = { + +type: 17, + +ids: $ReadOnlyArray, +}; + export type WorkerRequestMessage = | PingWorkerRequestMessage | InitWorkerRequestMessage @@ -167,7 +180,9 @@ | InitializeCryptoAccountRequestMessage | CreateIdentityServiceClientRequestMessage | CallIdentityClientMethodRequestMessage - | CallOLMApiMethodRequestMessage; + | CallOLMApiMethodRequestMessage + | GetReceivedMessagesToDeviceRequestMessage + | RemoveReceivedMessagesToDeviceRequestMessage; export type WorkerRequestProxyMessage = { +id: number, @@ -182,6 +197,7 @@ GET_PERSIST_STORAGE_ITEM: 3, CALL_IDENTITY_CLIENT_METHOD: 4, CALL_OLM_API_METHOD: 5, + GET_RECEIVED_MESSAGES_TO_DEVICE: 6, }); export type PongWorkerResponseMessage = { @@ -214,13 +230,19 @@ +result: mixed, }; +export type GetReceivedMessagesToDeviceResponseMessage = { + +type: 6, + +result: $ReadOnlyArray, +}; + export type WorkerResponseMessage = | PongWorkerResponseMessage | ClientStoreResponseMessage | GetCurrentUserIDResponseMessage | GetPersistStorageItemResponseMessage | CallIdentityClientMethodResponseMessage - | CallOLMApiMethodResponseMessage; + | CallOLMApiMethodResponseMessage + | GetReceivedMessagesToDeviceResponseMessage; export type WorkerResponseProxyMessage = { +id?: number,