Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32545994
D11164.1767179157.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D11164.1767179157.diff
View Options
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
@@ -13,7 +13,10 @@
import type { ClientReportCreationRequest } from './report-types.js';
import type { ClientDBThreadInfo, ThreadStore } from './thread-types.js';
import type { UserInfos } from './user-types.js';
-import type { ClientDBCommunityInfo } from '../ops/community-store-ops.js';
+import type {
+ ClientDBCommunityInfo,
+ ClientDBCommunityStoreOperation,
+} from '../ops/community-store-ops.js';
import type {
ClientDBKeyserverInfo,
ClientDBKeyserverStoreOperation,
@@ -52,6 +55,7 @@
+messageStoreOperations?: $ReadOnlyArray<ClientDBMessageStoreOperation>,
+reportStoreOperations?: $ReadOnlyArray<ClientDBReportStoreOperation>,
+keyserverStoreOperations?: $ReadOnlyArray<ClientDBKeyserverStoreOperation>,
+ +communityStoreOperations?: $ReadOnlyArray<ClientDBCommunityStoreOperation>,
};
export type ClientDBStore = {
diff --git a/web/database/worker/process-operations.js b/web/database/worker/process-operations.js
--- a/web/database/worker/process-operations.js
+++ b/web/database/worker/process-operations.js
@@ -1,5 +1,6 @@
// @flow
+import type { ClientDBCommunityStoreOperation } from 'lib/ops/community-store-ops.js';
import type { ClientDBKeyserverStoreOperation } from 'lib/ops/keyserver-store-ops.js';
import type { ClientDBReportStoreOperation } from 'lib/ops/report-store-ops.js';
import type { ClientDBThreadStoreOperation } from 'lib/ops/thread-store-ops.js';
@@ -154,6 +155,37 @@
}
}
+function processCommunityStoreOperations(
+ sqliteQueryExecutor: SQLiteQueryExecutor,
+ operations: $ReadOnlyArray<ClientDBCommunityStoreOperation>,
+ module: EmscriptenModule,
+) {
+ for (const operation: ClientDBCommunityStoreOperation of operations) {
+ try {
+ if (operation.type === 'remove_all_communities') {
+ sqliteQueryExecutor.removeAllCommunities();
+ } else if (operation.type === 'remove_communities') {
+ const { ids } = operation.payload;
+ sqliteQueryExecutor.removeCommunities(ids);
+ } else if (operation.type === 'replace_community') {
+ const { id, communityInfo } = operation.payload;
+ sqliteQueryExecutor.replaceCommunity({ id, communityInfo });
+ } else {
+ throw new Error('Unsupported community operation');
+ }
+ } catch (e) {
+ throw new Error(
+ `Error while processing ${
+ operation.type
+ } community operation: ${getProcessingStoreOpsExceptionMessage(
+ e,
+ module,
+ )}`,
+ );
+ }
+ }
+}
+
function processDBStoreOperations(
sqliteQueryExecutor: SQLiteQueryExecutor,
storeOperations: ClientDBStoreOperations,
@@ -164,6 +196,7 @@
reportStoreOperations,
threadStoreOperations,
keyserverStoreOperations,
+ communityStoreOperations,
} = storeOperations;
try {
@@ -196,6 +229,13 @@
module,
);
}
+ if (communityStoreOperations && communityStoreOperations.length > 0) {
+ processCommunityStoreOperations(
+ sqliteQueryExecutor,
+ communityStoreOperations,
+ module,
+ );
+ }
sqliteQueryExecutor.commitTransaction();
} catch (e) {
sqliteQueryExecutor.rollbackTransaction();
@@ -217,7 +257,7 @@
reports: sqliteQueryExecutor.getAllReports(),
users: [],
keyservers: sqliteQueryExecutor.getAllKeyservers(),
- communities: [],
+ communities: sqliteQueryExecutor.getAllCommunities(),
};
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 31, 11:05 AM (6 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5873218
Default Alt Text
D11164.1767179157.diff (3 KB)
Attached To
Mode
D11164: [sqlite] implement processing community store ops on worker
Attached
Detach File
Event Timeline
Log In to Comment