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 @@ -41,6 +41,9 @@ // read operations +getAllInboundP2PMessage: () => Promise, +getAllOutboundP2PMessage: () => Promise, + +getOutboundP2PMessagesByID: ( + ids: $ReadOnlyArray, + ) => Promise<$ReadOnlyArray>, // write operations +removeInboundP2PMessages: (ids: $ReadOnlyArray) => 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 @@ -35,6 +35,7 @@ getAllOutboundP2PMessage: jest.fn(), markOutboundP2PMessageAsSent: jest.fn(), removeOutboundP2PMessagesOlderThan: jest.fn(), + getOutboundP2PMessagesByID: 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 @@ -9,6 +9,7 @@ // read operations getAllInboundP2PMessage: commCoreModule.getAllInboundP2PMessage, getAllOutboundP2PMessage: commCoreModule.getAllOutboundP2PMessage, + getOutboundP2PMessagesByID: commCoreModule.getOutboundP2PMessagesByID, // write operations removeInboundP2PMessages: commCoreModule.removeInboundP2PMessages, 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 @@ -34,6 +34,20 @@ return messages ? [...messages] : []; }, + async getOutboundP2PMessagesByID( + ids: $ReadOnlyArray, + ): Promise<$ReadOnlyArray> { + const sharedWorker = await getCommSharedWorker(); + + const data = await sharedWorker.schedule({ + type: workerRequestMessageTypes.GET_OUTBOUND_P2P_MESSAGES_BY_ID, + messageIDs: ids, + }); + const messages: ?$ReadOnlyArray = + data?.outboundP2PMessages; + return messages ? [...messages] : []; + }, + // write operations async removeInboundP2PMessages(ids: $ReadOnlyArray): Promise { const sharedWorker = await getCommSharedWorker(); 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 @@ -252,6 +252,15 @@ type: workerResponseMessageTypes.GET_OUTBOUND_P2P_MESSAGES, outboundP2PMessages: sqliteQueryExecutor.getAllOutboundP2PMessages(), }; + } else if ( + message.type === workerRequestMessageTypes.GET_OUTBOUND_P2P_MESSAGES_BY_ID + ) { + return { + type: workerResponseMessageTypes.GET_OUTBOUND_P2P_MESSAGES, + outboundP2PMessages: sqliteQueryExecutor.getOutboundP2PMessagesByID( + message.messageIDs, + ), + }; } // write operations 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 @@ -43,6 +43,7 @@ GET_OUTBOUND_P2P_MESSAGES: 18, MARK_OUTBOUND_P2P_MESSAGE_AS_SENT: 19, REMOVE_OUTBOUND_P2P_MESSAGES: 20, + GET_OUTBOUND_P2P_MESSAGES_BY_ID: 21, }); export const workerWriteRequests: $ReadOnlyArray = [ @@ -188,6 +189,11 @@ +deviceID: string, }; +export type GetOutboundP2PMessageRequestMessage = { + +type: 21, + +messageIDs: $ReadOnlyArray, +}; + export type WorkerRequestMessage = | PingWorkerRequestMessage | InitWorkerRequestMessage @@ -209,7 +215,8 @@ | RemoveInboundP2PMessagesRequestMessage | GetOutboundP2PMessagesRequestMessage | MarkOutboundP2PMessageAsSentRequestMessage - | RemoveOutboundP2PMessagesRequestMessage; + | RemoveOutboundP2PMessagesRequestMessage + | GetOutboundP2PMessageRequestMessage; export type WorkerRequestProxyMessage = { +id: number,