Page MenuHomePhabricator

D7600.diff
No OneTemporary

D7600.diff

diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js
--- a/lib/types/thread-types.js
+++ b/lib/types/thread-types.js
@@ -510,3 +510,5 @@
// We can show a max of 5 sidebars inline underneath their parent
// in the chat tab if every one of the displayed sidebars is unread
export const maxUnreadSidebars = 5;
+
+export type ThreadStoreThreadInfos = { +[id: string]: RawThreadInfo };
diff --git a/native/redux/client-db-utils.js b/native/redux/client-db-utils.js
--- a/native/redux/client-db-utils.js
+++ b/native/redux/client-db-utils.js
@@ -4,6 +4,7 @@
ClientDBThreadInfo,
ClientDBThreadStoreOperation,
RawThreadInfo,
+ ThreadStoreThreadInfos,
} from 'lib/types/thread-types.js';
import {
convertClientDBThreadInfoToRawThreadInfo,
@@ -13,8 +14,6 @@
import type { AppState } from './state-types.js';
import { commCoreModule } from '../native-modules.js';
-type ThreadStoreThreadInfos = { +[id: string]: RawThreadInfo };
-
function updateClientDBThreadStoreThreadInfos(
state: AppState,
migrationFunc: ThreadStoreThreadInfos => ThreadStoreThreadInfos,
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -42,10 +42,12 @@
convertThreadStoreOperationsToClientDBOperations,
} from 'lib/utils/thread-ops-utils.js';
+import { updateClientDBThreadStoreThreadInfos } from './client-db-utils.js';
import { migrateThreadStoreForEditThreadPermissions } from './edit-thread-permission-migration.js';
import { persistMigrationForManagePinsThreadPermission } from './manage-pins-permission-migration.js';
import type { AppState } from './state-types.js';
import { unshimClientDB } from './unshim-utils.js';
+import { updateRolesAndPermissions } from './update-roles-and-permissions.js';
import { commCoreModule } from '../native-modules.js';
import { defaultDeviceCameraInfo } from '../types/camera.js';
import { defaultGlobalThemeInfo } from '../types/themes.js';
@@ -528,6 +530,8 @@
return state;
},
+ [38]: state =>
+ updateClientDBThreadStoreThreadInfos(state, updateRolesAndPermissions),
};
// After migration 31, we'll no longer want to persist `messageStore.messages`
diff --git a/native/redux/update-roles-and-permissions.js b/native/redux/update-roles-and-permissions.js
new file mode 100644
--- /dev/null
+++ b/native/redux/update-roles-and-permissions.js
@@ -0,0 +1,39 @@
+// @flow
+
+import type { ThreadStoreThreadInfos } from 'lib/types/thread-types.js';
+import { values } from 'lib/utils/objects.js';
+
+type ThreadTraversalNode = {
+ +threadID: string,
+ +children: ?$ReadOnlyArray<ThreadTraversalNode>,
+};
+
+function constructThreadTraversalNodes(
+ threadStoreInfos: ThreadStoreThreadInfos,
+): $ReadOnlyArray<ThreadTraversalNode> {
+ const parentThreadMap = {};
+
+ for (const threadInfo of values(threadStoreInfos)) {
+ const parentThreadID = threadInfo.parentThreadID ?? 'root';
+ parentThreadMap[parentThreadID] = [
+ ...(parentThreadMap[parentThreadID] ?? []),
+ threadInfo.id,
+ ];
+ }
+
+ const constructNodes = nodeID => ({
+ threadID: nodeID,
+ children: parentThreadMap[nodeID]?.map(constructNodes) ?? null,
+ });
+
+ return parentThreadMap['root'].map(constructNodes);
+}
+
+function updateRolesAndPermissions(
+ threadStoreInfos: ThreadStoreThreadInfos,
+): ThreadStoreThreadInfos {
+ constructThreadTraversalNodes(threadStoreInfos);
+ return threadStoreInfos;
+}
+
+export { updateRolesAndPermissions };

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 2:02 PM (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2452779
Default Alt Text
D7600.diff (3 KB)

Event Timeline