Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3528840
D12745.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D12745.diff
View Options
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
@@ -40,9 +40,14 @@
export type SQLiteAPI = {
// read operations
- +getAllInboundP2PMessage: () => Promise<InboundP2PMessage[]>,
- +getAllOutboundP2PMessage: () => Promise<OutboundP2PMessage[]>,
- +getRelatedMessages: (messageID: string) => Promise<ClientDBMessageInfo[]>,
+ +getAllInboundP2PMessage: () => Promise<Array<InboundP2PMessage>>,
+ +getAllOutboundP2PMessage: () => Promise<Array<OutboundP2PMessage>>,
+ +getRelatedMessages: (
+ messageID: string,
+ ) => Promise<Array<ClientDBMessageInfo>>,
+ +getOutboundP2PMessagesByID: (
+ ids: $ReadOnlyArray<string>,
+ ) => Promise<Array<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/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -156,7 +156,7 @@
+removeInboundP2PMessages: (ids: $ReadOnlyArray<string>) => Promise<void>;
+getOutboundP2PMessagesByID: (
ids: $ReadOnlyArray<string>,
- ) => Promise<$ReadOnlyArray<OutboundP2PMessage>>;
+ ) => Promise<Array<OutboundP2PMessage>>;
+getAllOutboundP2PMessage: () => Promise<OutboundP2PMessage[]>;
+markOutboundP2PMessageAsSent: (
messageID: string,
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<Array<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 GetOutboundP2PMessagesByIDRequestMessage = {
+ +type: 22,
+ +messageIDs: $ReadOnlyArray<string>,
+};
+
export type WorkerRequestMessage =
| PingWorkerRequestMessage
| InitWorkerRequestMessage
@@ -217,7 +223,8 @@
| GetOutboundP2PMessagesRequestMessage
| MarkOutboundP2PMessageAsSentRequestMessage
| RemoveOutboundP2PMessagesRequestMessage
- | GetRelatedMessagesRequestMessage;
+ | GetRelatedMessagesRequestMessage
+ | GetOutboundP2PMessagesByIDRequestMessage;
export type WorkerRequestProxyMessage = {
+id: number,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 10:33 AM (1 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2702553
Default Alt Text
D12745.diff (4 KB)
Attached To
Mode
D12745: [native][web] Introduce a method fetching messages by ID to SQLiteAPI
Attached
Detach File
Event Timeline
Log In to Comment