Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3146451
D12061.id41201.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12061.id41201.diff
View Options
diff --git a/lib/shared/redux/legacy-update-roles-and-permissions.js b/lib/shared/redux/legacy-update-roles-and-permissions.js
--- a/lib/shared/redux/legacy-update-roles-and-permissions.js
+++ b/lib/shared/redux/legacy-update-roles-and-permissions.js
@@ -10,6 +10,7 @@
import type { ThreadPermissionsBlob } from '../../types/thread-permission-types.js';
import type {
LegacyRawThreadInfo,
+ LegacyRawThreadInfos,
ThreadStoreThreadInfos,
LegacyMemberInfo,
MixedRawThreadInfos,
@@ -53,7 +54,7 @@
// This migration utility can only be used with LegacyRawThreadInfos
function legacyUpdateRolesAndPermissions(
threadStoreInfos: MixedRawThreadInfos,
-): MixedRawThreadInfos {
+): LegacyRawThreadInfos {
const updatedThreadStoreInfos = assertAllThreadInfosAreLegacy({
...threadStoreInfos,
});
diff --git a/lib/shared/redux/update-roles-and-permissions.js b/lib/shared/redux/update-roles-and-permissions.js
new file mode 100644
--- /dev/null
+++ b/lib/shared/redux/update-roles-and-permissions.js
@@ -0,0 +1,47 @@
+// @flow
+
+import { legacyUpdateRolesAndPermissions } from './legacy-update-roles-and-permissions.js';
+import {
+ decodeMinimallyEncodedRawThreadInfo,
+ minimallyEncodeRawThreadInfo,
+ type RawThreadInfo,
+} from '../../types/minimally-encoded-thread-permissions-types.js';
+import type {
+ RawThreadInfos,
+ LegacyRawThreadInfo,
+} from '../../types/thread-types.js';
+
+function updateRolesAndPermissions(
+ threadStoreInfos: RawThreadInfos,
+): RawThreadInfos {
+ const decodedThreadStoreInfos: { [id: string]: LegacyRawThreadInfo } = {};
+
+ for (const threadID in threadStoreInfos) {
+ const rawThreadInfo = threadStoreInfos[threadID];
+
+ const decodedThreadInfo =
+ decodeMinimallyEncodedRawThreadInfo(rawThreadInfo);
+
+ decodedThreadStoreInfos[threadID] = decodedThreadInfo;
+ }
+
+ const updatedDecodedThreadStoreInfos = legacyUpdateRolesAndPermissions(
+ decodedThreadStoreInfos,
+ );
+
+ const updatedThreadStoreInfos: { [id: string]: RawThreadInfo } = {};
+
+ for (const threadID in updatedDecodedThreadStoreInfos) {
+ const updatedThreadInfo: LegacyRawThreadInfo =
+ updatedDecodedThreadStoreInfos[threadID];
+
+ const encodedUpdatedThreadInfo =
+ minimallyEncodeRawThreadInfo(updatedThreadInfo);
+
+ updatedThreadStoreInfos[threadID] = encodedUpdatedThreadInfo;
+ }
+
+ return updatedThreadStoreInfos;
+}
+
+export { updateRolesAndPermissions };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 5, 1:50 AM (5 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2420012
Default Alt Text
D12061.id41201.diff (2 KB)
Attached To
Mode
D12061: [lib] introduce new updateRolesAndPermissions migration util
Attached
Detach File
Event Timeline
Log In to Comment