Page MenuHomePhabricator

D12500.diff
No OneTemporary

D12500.diff

diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -59,7 +59,9 @@
import { patchRawThreadInfosWithSpecialRole } from 'lib/permissions/special-roles.js';
import { filterThreadIDsInFilterList } from 'lib/reducers/calendar-filters-reducer.js';
import { highestLocalIDSelector } from 'lib/selectors/local-id-selectors.js';
+import { createUpdateDBOpsForThreadStoreThreadInfos } from 'lib/shared/redux/client-db-utils.js';
import { legacyUpdateRolesAndPermissions } from 'lib/shared/redux/legacy-update-roles-and-permissions.js';
+import { updateRolesAndPermissions } from 'lib/shared/redux/update-roles-and-permissions.js';
import { inconsistencyResponsesToReports } from 'lib/shared/report-utils.js';
import {
getContainingThreadID,
@@ -1387,6 +1389,19 @@
state,
ops: [],
}),
+ [78]: (state: AppState) => {
+ const clientDBThreadInfos = commCoreModule.getAllThreadsSync();
+
+ const dbOperations = createUpdateDBOpsForThreadStoreThreadInfos(
+ clientDBThreadInfos,
+ updateRolesAndPermissions,
+ );
+
+ return {
+ state,
+ ops: dbOperations,
+ };
+ },
};
// NOTE: renaming this object, and especially the `version` property
@@ -1397,7 +1412,7 @@
storage: AsyncStorage,
blacklist: persistBlacklist,
debug: __DEV__,
- version: 77,
+ version: 78,
transforms: [
messageStoreMessagesBlocklistTransform,
reportStoreTransform,
diff --git a/web/redux/persist-constants.js b/web/redux/persist-constants.js
--- a/web/redux/persist-constants.js
+++ b/web/redux/persist-constants.js
@@ -3,6 +3,6 @@
const rootKey = 'root';
const rootKeyPrefix = 'persist:';
const completeRootKey = `${rootKeyPrefix}${rootKey}`;
-const storeVersion = 77;
+const storeVersion = 78;
export { rootKey, rootKeyPrefix, completeRootKey, storeVersion };
diff --git a/web/redux/persist.js b/web/redux/persist.js
--- a/web/redux/persist.js
+++ b/web/redux/persist.js
@@ -18,6 +18,8 @@
} from 'lib/ops/message-store-ops.js';
import type { ClientDBThreadStoreOperation } from 'lib/ops/thread-store-ops.js';
import { patchRawThreadInfoWithSpecialRole } from 'lib/permissions/special-roles.js';
+import { createUpdateDBOpsForThreadStoreThreadInfos } from 'lib/shared/redux/client-db-utils.js';
+import { updateRolesAndPermissions } from 'lib/shared/redux/update-roles-and-permissions.js';
import { keyserverStoreTransform } from 'lib/shared/transforms/keyserver-store-transform.js';
import { messageStoreMessagesBlocklistTransform } from 'lib/shared/transforms/message-store-transform.js';
import { defaultAlertInfos } from 'lib/types/alert-types.js';
@@ -556,6 +558,47 @@
state,
ops: [],
}),
+ [78]: async (state: AppState) => {
+ // 1. Check if `databaseModule` is supported and early-exit if not.
+ const sharedWorker = await getCommSharedWorker();
+ const isDatabaseSupported = await sharedWorker.isSupported();
+
+ if (!isDatabaseSupported) {
+ return {
+ state,
+ ops: [],
+ };
+ }
+
+ // 2. Get existing `stores` from SQLite.
+ const stores = await sharedWorker.schedule({
+ type: workerRequestMessageTypes.GET_CLIENT_STORE,
+ });
+
+ const clientDBThreadInfos: ?$ReadOnlyArray<ClientDBThreadInfo> =
+ stores?.store?.threads;
+
+ if (
+ clientDBThreadInfos === null ||
+ clientDBThreadInfos === undefined ||
+ clientDBThreadInfos.length === 0
+ ) {
+ return {
+ state,
+ ops: [],
+ };
+ }
+
+ const dbOperations = createUpdateDBOpsForThreadStoreThreadInfos(
+ clientDBThreadInfos,
+ updateRolesAndPermissions,
+ );
+
+ return {
+ state,
+ ops: dbOperations,
+ };
+ },
};
const persistConfig: PersistConfig = {

File Metadata

Mime Type
text/plain
Expires
Sun, Sep 29, 3:18 AM (22 h, 33 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2198768
Default Alt Text
D12500.diff (3 KB)

Event Timeline