Page MenuHomePhabricator

D12745.id42342.diff
No OneTemporary

D12745.id42342.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
@@ -41,6 +41,9 @@
// read operations
+getAllInboundP2PMessage: () => Promise<InboundP2PMessage[]>,
+getAllOutboundP2PMessage: () => Promise<OutboundP2PMessage[]>,
+ +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
@@ -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<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
@@ -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<number> = [
@@ -188,6 +189,11 @@
+deviceID: string,
};
+export type GetOutboundP2PMessageRequestMessage = {
+ +type: 21,
+ +messageIDs: $ReadOnlyArray<string>,
+};
+
export type WorkerRequestMessage =
| PingWorkerRequestMessage
| InitWorkerRequestMessage
@@ -209,7 +215,8 @@
| RemoveInboundP2PMessagesRequestMessage
| GetOutboundP2PMessagesRequestMessage
| MarkOutboundP2PMessageAsSentRequestMessage
- | RemoveOutboundP2PMessagesRequestMessage;
+ | RemoveOutboundP2PMessagesRequestMessage
+ | GetOutboundP2PMessageRequestMessage;
export type WorkerRequestProxyMessage = {
+id: number,

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 10:03 PM (12 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2703290
Default Alt Text
D12745.id42342.diff (3 KB)

Event Timeline