Page MenuHomePhabricator

D12745.id42390.diff
No OneTemporary

D12745.id42390.diff

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
@@ -43,6 +43,9 @@
+getAllInboundP2PMessage: () => Promise<InboundP2PMessage[]>,
+getAllOutboundP2PMessage: () => Promise<OutboundP2PMessage[]>,
+getRelatedMessages: (messageID: string) => Promise<ClientDBMessageInfo[]>,
+ +getOutboundP2PMessagesByID: (
+ ids: $ReadOnlyArray<string>,
+ ) => Promise<$ReadOnlyArray<OutboundP2PMessage>>,
// write operations
+removeInboundP2PMessages: (ids: $ReadOnlyArray<string>) => Promise<void>,
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
@@ -36,6 +36,7 @@
markOutboundP2PMessageAsSent: jest.fn(),
removeOutboundP2PMessagesOlderThan: jest.fn(),
getRelatedMessages: 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
@@ -10,6 +10,7 @@
getAllInboundP2PMessage: commCoreModule.getAllInboundP2PMessage,
getAllOutboundP2PMessage: commCoreModule.getAllOutboundP2PMessage,
getRelatedMessages: commCoreModule.getRelatedMessages,
+ 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
@@ -46,6 +46,20 @@
return messages ? [...messages] : [];
},
+ async getOutboundP2PMessagesByID(
+ ids: $ReadOnlyArray<string>,
+ ): Promise<$ReadOnlyArray<OutboundP2PMessage>> {
+ const sharedWorker = await getCommSharedWorker();
+
+ const data = await sharedWorker.schedule({
+ type: workerRequestMessageTypes.GET_OUTBOUND_P2P_MESSAGES_BY_ID,
+ messageIDs: ids,
+ });
+ const messages: ?$ReadOnlyArray<OutboundP2PMessage> =
+ data?.outboundP2PMessages;
+ return messages ? [...messages] : [];
+ },
+
// write operations
async removeInboundP2PMessages(ids: $ReadOnlyArray<string>): Promise<void> {
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
@@ -261,6 +261,15 @@
type: workerResponseMessageTypes.GET_RELATED_MESSAGES,
messages: webMessageEntities.map(webMessageToClientDBMessageInfo),
};
+ } 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
@@ -45,6 +45,7 @@
MARK_OUTBOUND_P2P_MESSAGE_AS_SENT: 19,
REMOVE_OUTBOUND_P2P_MESSAGES: 20,
GET_RELATED_MESSAGES: 21,
+ GET_OUTBOUND_P2P_MESSAGES_BY_ID: 22,
});
export const workerWriteRequests: $ReadOnlyArray<number> = [
@@ -195,6 +196,11 @@
+messageID: string,
};
+export type GetOutboundP2PMessageRequestMessage = {
+ +type: 22,
+ +messageIDs: $ReadOnlyArray<string>,
+};
+
export type WorkerRequestMessage =
| PingWorkerRequestMessage
| InitWorkerRequestMessage
@@ -217,7 +223,8 @@
| GetOutboundP2PMessagesRequestMessage
| MarkOutboundP2PMessageAsSentRequestMessage
| RemoveOutboundP2PMessagesRequestMessage
- | GetRelatedMessagesRequestMessage;
+ | GetRelatedMessagesRequestMessage
+ | GetOutboundP2PMessageRequestMessage;
export type WorkerRequestProxyMessage = {
+id: number,

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 5, 2:04 PM (15 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2426158
Default Alt Text
D12745.id42390.diff (3 KB)

Event Timeline