Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3186010
D7600.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7600.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D7600: [native] Introduce `constructThreadTraversalNodes(...)`
Attached
Detach File
Event Timeline
Log In to Comment