Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3346530
D12078.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
D12078.diff
View Options
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
@@ -14,7 +14,8 @@
const data = await sharedWorker.schedule({
type: workerRequestMessageTypes.GET_INBOUND_P2P_MESSAGES,
});
- const messages: ?$ReadOnlyArray<InboundP2PMessage> = data?.messages;
+ const messages: ?$ReadOnlyArray<InboundP2PMessage> =
+ data?.inboundP2PMessages;
return messages ? [...messages] : [];
},
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
@@ -243,7 +243,14 @@
) {
return {
type: workerResponseMessageTypes.GET_INBOUND_P2P_MESSAGES,
- messages: sqliteQueryExecutor.getAllInboundP2PMessage(),
+ inboundP2PMessages: sqliteQueryExecutor.getAllInboundP2PMessage(),
+ };
+ } else if (
+ message.type === workerRequestMessageTypes.GET_OUTBOUND_P2P_MESSAGES
+ ) {
+ return {
+ type: workerResponseMessageTypes.GET_OUTBOUND_P2P_MESSAGES,
+ outboundP2PMessages: sqliteQueryExecutor.getAllOutboundP2PMessages(),
};
}
@@ -314,6 +321,20 @@
message.type === workerRequestMessageTypes.REMOVE_INBOUND_P2P_MESSAGES
) {
sqliteQueryExecutor.removeInboundP2PMessages(message.ids);
+ } else if (
+ message.type === workerRequestMessageTypes.MARK_OUTBOUND_P2P_MESSAGE_AS_SENT
+ ) {
+ sqliteQueryExecutor.markOutboundP2PMessageAsSent(
+ message.messageID,
+ message.deviceID,
+ );
+ } else if (
+ message.type === workerRequestMessageTypes.REMOVE_OUTBOUND_P2P_MESSAGES
+ ) {
+ sqliteQueryExecutor.removeOutboundP2PMessagesOlderThan(
+ message.messageID,
+ message.deviceID,
+ );
}
persistNeeded = true;
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,7 +11,10 @@
IdentityServiceClient,
IdentityServiceAuthLayer,
} from 'lib/types/identity-service-types.js';
-import type { InboundP2PMessage } from 'lib/types/sqlite-types.js';
+import type {
+ InboundP2PMessage,
+ OutboundP2PMessage,
+} from 'lib/types/sqlite-types.js';
import type {
ClientDBStore,
ClientDBStoreOperations,
@@ -37,6 +40,9 @@
CALL_OLM_API_METHOD: 15,
GET_INBOUND_P2P_MESSAGES: 16,
REMOVE_INBOUND_P2P_MESSAGES: 17,
+ GET_OUTBOUND_P2P_MESSAGES: 18,
+ MARK_OUTBOUND_P2P_MESSAGE_AS_SENT: 19,
+ REMOVE_OUTBOUND_P2P_MESSAGES: 20,
});
export const workerWriteRequests: $ReadOnlyArray<number> = [
@@ -47,6 +53,8 @@
workerRequestMessageTypes.BACKUP_RESTORE,
workerRequestMessageTypes.INITIALIZE_CRYPTO_ACCOUNT,
workerRequestMessageTypes.REMOVE_INBOUND_P2P_MESSAGES,
+ workerRequestMessageTypes.MARK_OUTBOUND_P2P_MESSAGE_AS_SENT,
+ workerRequestMessageTypes.REMOVE_OUTBOUND_P2P_MESSAGES,
];
export const workerOlmAPIRequests: $ReadOnlyArray<number> = [
@@ -164,6 +172,22 @@
+ids: $ReadOnlyArray<string>,
};
+export type GetOutboundP2PMessagesRequestMessage = {
+ +type: 18,
+};
+
+export type MarkOutboundP2PMessageAsSentRequestMessage = {
+ +type: 19,
+ +messageID: string,
+ +deviceID: string,
+};
+
+export type RemoveOutboundP2PMessagesRequestMessage = {
+ +type: 20,
+ +messageID: string,
+ +deviceID: string,
+};
+
export type WorkerRequestMessage =
| PingWorkerRequestMessage
| InitWorkerRequestMessage
@@ -182,7 +206,10 @@
| CallIdentityClientMethodRequestMessage
| CallOLMApiMethodRequestMessage
| GetInboundP2PMessagesRequestMessage
- | RemoveInboundP2PMessagesRequestMessage;
+ | RemoveInboundP2PMessagesRequestMessage
+ | GetOutboundP2PMessagesRequestMessage
+ | MarkOutboundP2PMessageAsSentRequestMessage
+ | RemoveOutboundP2PMessagesRequestMessage;
export type WorkerRequestProxyMessage = {
+id: number,
@@ -198,6 +225,7 @@
CALL_IDENTITY_CLIENT_METHOD: 4,
CALL_OLM_API_METHOD: 5,
GET_INBOUND_P2P_MESSAGES: 6,
+ GET_OUTBOUND_P2P_MESSAGES: 7,
});
export type PongWorkerResponseMessage = {
@@ -232,7 +260,12 @@
export type GetInboundP2PMessagesResponseMessage = {
+type: 6,
- +messages: $ReadOnlyArray<InboundP2PMessage>,
+ +inboundP2PMessages: $ReadOnlyArray<InboundP2PMessage>,
+};
+
+export type GetOutboundP2PMessagesResponseMessage = {
+ +type: 7,
+ +outboundP2PMessages: $ReadOnlyArray<OutboundP2PMessage>,
};
export type WorkerResponseMessage =
@@ -242,7 +275,8 @@
| GetPersistStorageItemResponseMessage
| CallIdentityClientMethodResponseMessage
| CallOLMApiMethodResponseMessage
- | GetInboundP2PMessagesResponseMessage;
+ | GetInboundP2PMessagesResponseMessage
+ | GetOutboundP2PMessagesResponseMessage;
export type WorkerResponseProxyMessage = {
+id?: number,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 9:01 AM (19 h, 52 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569985
Default Alt Text
D12078.diff (4 KB)
Attached To
Mode
D12078: [web] implement Outbound P2P Messages API on worker
Attached
Detach File
Event Timeline
Log In to Comment