Page MenuHomePhabricator

D12801.id42653.diff
No OneTemporary

D12801.id42653.diff

diff --git a/lib/message-search-types.js b/lib/message-search-types.js
new file mode 100644
--- /dev/null
+++ b/lib/message-search-types.js
@@ -0,0 +1,13 @@
+// @flow
+
+type UpdateSearchMessageOperation = {
+ +type: 'update_search_messages',
+ +payload: {
+ +originalMessageID: string,
+ +messageID: string,
+ +content: string,
+ },
+};
+
+export type MessageSearchStoreOperation = UpdateSearchMessageOperation;
+export type ClientDBMessageSearchStoreOperation = MessageSearchStoreOperation;
diff --git a/lib/types/store-ops-types.js b/lib/types/store-ops-types.js
--- a/lib/types/store-ops-types.js
+++ b/lib/types/store-ops-types.js
@@ -22,6 +22,7 @@
import type { ThreadActivityStore } from './thread-activity-types.js';
import type { ClientDBThreadInfo, ThreadStore } from './thread-types.js';
import type { UserInfos } from './user-types.js';
+import type { ClientDBMessageSearchStoreOperation } from '../message-search-types.js';
import type {
ClientDBAuxUserInfo,
ClientDBAuxUserStoreOperation,
@@ -105,6 +106,7 @@
+threadActivityStoreOperations?: $ReadOnlyArray<ClientDBThreadActivityStoreOperation>,
+outboundP2PMessages?: $ReadOnlyArray<OutboundP2PMessage>,
+entryStoreOperations?: $ReadOnlyArray<ClientDBEntryStoreOperation>,
+ +messageSearchStoreOperations?: $ReadOnlyArray<ClientDBMessageSearchStoreOperation>,
};
export type ClientDBStore = {
diff --git a/web/shared-worker/worker/process-operations.js b/web/shared-worker/worker/process-operations.js
--- a/web/shared-worker/worker/process-operations.js
+++ b/web/shared-worker/worker/process-operations.js
@@ -1,5 +1,6 @@
// @flow
+import type { ClientDBMessageSearchStoreOperation } from 'lib/message-search-types.js';
import type { ClientDBAuxUserStoreOperation } from 'lib/ops/aux-user-store-ops.js';
import type { ClientDBCommunityStoreOperation } from 'lib/ops/community-store-ops.js';
import type { ClientDBEntryStoreOperation } from 'lib/ops/entries-store-ops.js';
@@ -376,6 +377,7 @@
threadActivityStoreOperations,
outboundP2PMessages,
entryStoreOperations,
+ messageSearchStoreOperations,
} = storeOperations;
try {
@@ -473,6 +475,16 @@
module,
);
}
+ if (
+ messageSearchStoreOperations &&
+ messageSearchStoreOperations.length > 0
+ ) {
+ processMessageSearchStoreOperations(
+ sqliteQueryExecutor,
+ messageSearchStoreOperations,
+ module,
+ );
+ }
sqliteQueryExecutor.commitTransaction();
} catch (e) {
sqliteQueryExecutor.rollbackTransaction();
@@ -577,6 +589,34 @@
}
}
+function processMessageSearchStoreOperations(
+ sqliteQueryExecutor: SQLiteQueryExecutor,
+ operations: $ReadOnlyArray<ClientDBMessageSearchStoreOperation>,
+ module: EmscriptenModule,
+) {
+ for (const operation: ClientDBMessageSearchStoreOperation of operations) {
+ try {
+ if (operation.type === 'update_search_messages') {
+ const { originalMessageID, messageID, content } = operation.payload;
+ sqliteQueryExecutor.updateMessageSearchIndex(
+ originalMessageID,
+ messageID,
+ content,
+ );
+ }
+ } catch (e) {
+ throw new Error(
+ `Error while processing ${
+ operation.type
+ } message search operation: ${getProcessingStoreOpsExceptionMessage(
+ e,
+ module,
+ )}`,
+ );
+ }
+ }
+}
+
function getClientStoreFromQueryExecutor(
sqliteQueryExecutor: SQLiteQueryExecutor,
): ClientDBStore {

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 8:36 PM (20 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594852
Default Alt Text
D12801.id42653.diff (3 KB)

Event Timeline