Page MenuHomePhabricator

D12061.diff
No OneTemporary

D12061.diff

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

Mime Type
text/plain
Expires
Fri, Oct 18, 3:42 PM (13 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2318194
Default Alt Text
D12061.diff (2 KB)

Event Timeline