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 @@ -39,6 +39,7 @@ } from '../../types/worker-types.js'; import { workerIdentityClientRequests } from '../../types/worker-types.js'; import { getDatabaseModule } from '../db-module.js'; +import { webMessageToClientDBMessageInfo } from '../types/entities.js'; import { COMM_SQLITE_DATABASE_PATH, SQLITE_STAMPED_USER_ID_KEY, @@ -252,6 +253,19 @@ type: workerResponseMessageTypes.GET_OUTBOUND_P2P_MESSAGES, outboundP2PMessages: sqliteQueryExecutor.getAllOutboundP2PMessages(), }; + } else if ( + message.type === workerRequestMessageTypes.GET_LATEST_MESSAGE_EDIT + ) { + const webMessageEntity = sqliteQueryExecutor.getLatestMessageEditWeb( + message.messageID, + ); + const result = webMessageEntity + ? webMessageToClientDBMessageInfo(webMessageEntity) + : undefined; + return { + type: workerResponseMessageTypes.GET_LATEST_MESSAGE_EDIT, + message: result, + }; } // 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 @@ -11,6 +11,7 @@ IdentityServiceClient, IdentityServiceAuthLayer, } from 'lib/types/identity-service-types.js'; +import type { ClientDBMessageInfo } from 'lib/types/message-types.js'; import type { InboundP2PMessage, OutboundP2PMessage, @@ -43,6 +44,7 @@ GET_OUTBOUND_P2P_MESSAGES: 18, MARK_OUTBOUND_P2P_MESSAGE_AS_SENT: 19, REMOVE_OUTBOUND_P2P_MESSAGES: 20, + GET_LATEST_MESSAGE_EDIT: 21, }); export const workerWriteRequests: $ReadOnlyArray = [ @@ -188,6 +190,11 @@ +deviceID: string, }; +export type GetLatestMessageEditRequestMessage = { + +type: 21, + +messageID: string, +}; + export type WorkerRequestMessage = | PingWorkerRequestMessage | InitWorkerRequestMessage @@ -209,7 +216,8 @@ | RemoveInboundP2PMessagesRequestMessage | GetOutboundP2PMessagesRequestMessage | MarkOutboundP2PMessageAsSentRequestMessage - | RemoveOutboundP2PMessagesRequestMessage; + | RemoveOutboundP2PMessagesRequestMessage + | GetLatestMessageEditRequestMessage; export type WorkerRequestProxyMessage = { +id: number, @@ -226,6 +234,7 @@ CALL_OLM_API_METHOD: 5, GET_INBOUND_P2P_MESSAGES: 6, GET_OUTBOUND_P2P_MESSAGES: 7, + GET_LATEST_MESSAGE_EDIT: 8, }); export type PongWorkerResponseMessage = { @@ -268,6 +277,11 @@ +outboundP2PMessages: $ReadOnlyArray, }; +export type GetLatestMessageEditResponseMessage = { + +type: 8, + +message: ?ClientDBMessageInfo, +}; + export type WorkerResponseMessage = | PongWorkerResponseMessage | ClientStoreResponseMessage @@ -276,7 +290,8 @@ | CallIdentityClientMethodResponseMessage | CallOLMApiMethodResponseMessage | GetInboundP2PMessagesResponseMessage - | GetOutboundP2PMessagesResponseMessage; + | GetOutboundP2PMessagesResponseMessage + | GetLatestMessageEditResponseMessage; export type WorkerResponseProxyMessage = { +id?: number,