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 @@ -270,6 +270,17 @@ message.messageIDs, ), }; + } else if (message.type === workerRequestMessageTypes.SEARCH_MESSAGES) { + const webMessageEntities = sqliteQueryExecutor.searchMessages( + message.query, + message.threadID, + message.timestampCursor, + message.messageIDCursor, + ); + return { + type: workerResponseMessageTypes.SEARCH_MESSAGES, + messages: webMessageEntities.map(webMessageToClientDBMessageInfo), + }; } // 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 @@ -46,6 +46,7 @@ REMOVE_OUTBOUND_P2P_MESSAGES: 20, GET_RELATED_MESSAGES: 21, GET_OUTBOUND_P2P_MESSAGES_BY_ID: 22, + SEARCH_MESSAGES: 23, }); export const workerWriteRequests: $ReadOnlyArray = [ @@ -201,6 +202,14 @@ +messageIDs: $ReadOnlyArray, }; +export type SearchMessagesRequestMessage = { + +type: 23, + +query: string, + +threadID: string, + +timestampCursor: ?string, + +messageIDCursor: ?string, +}; + export type WorkerRequestMessage = | PingWorkerRequestMessage | InitWorkerRequestMessage @@ -224,7 +233,8 @@ | MarkOutboundP2PMessageAsSentRequestMessage | RemoveOutboundP2PMessagesRequestMessage | GetRelatedMessagesRequestMessage - | GetOutboundP2PMessagesByIDRequestMessage; + | GetOutboundP2PMessagesByIDRequestMessage + | SearchMessagesRequestMessage; export type WorkerRequestProxyMessage = { +id: number, @@ -242,6 +252,7 @@ GET_INBOUND_P2P_MESSAGES: 6, GET_OUTBOUND_P2P_MESSAGES: 7, GET_RELATED_MESSAGES: 8, + SEARCH_MESSAGES: 9, }); export type PongWorkerResponseMessage = { @@ -289,6 +300,11 @@ +messages: $ReadOnlyArray, }; +export type SearchMessagesResponseMessage = { + +type: 9, + +messages: $ReadOnlyArray, +}; + export type WorkerResponseMessage = | PongWorkerResponseMessage | ClientStoreResponseMessage @@ -298,7 +314,8 @@ | CallOLMApiMethodResponseMessage | GetInboundP2PMessagesResponseMessage | GetOutboundP2PMessagesResponseMessage - | GetRelatedMessagesResponseMessage; + | GetRelatedMessagesResponseMessage + | SearchMessagesResponseMessage; export type WorkerResponseProxyMessage = { +id?: number,