diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -82,21 +82,22 @@ threadTypeIsCommunityRoot, assertThreadType, } from '../types/thread-types-enum.js'; -import { - type LegacyRawThreadInfo, - type LegacyThreadInfo, - type MemberInfo, - type ServerThreadInfo, - type ThreadCurrentUserInfo, - type RoleInfo, - type ServerMemberInfo, - type ClientNewThreadRequest, - type NewThreadResult, - type ChangeThreadSettingsPayload, - type UserProfileThreadInfo, - type RelativeMemberInfo, - type RawThreadInfo, - type ThreadInfo, +import type { + LegacyRawThreadInfo, + LegacyThreadInfo, + MemberInfo, + ServerThreadInfo, + ThreadCurrentUserInfo, + RoleInfo, + ServerMemberInfo, + ClientNewThreadRequest, + NewThreadResult, + ChangeThreadSettingsPayload, + UserProfileThreadInfo, + RelativeMemberInfo, + RawThreadInfo, + ThreadInfo, + RawThreadInfos, } from '../types/thread-types.js'; import { updateTypes } from '../types/update-types-enum.js'; import { type ClientUpdateInfo } from '../types/update-types.js'; @@ -1756,6 +1757,19 @@ ]); } +function assertAllThreadInfosAreLegacy(rawThreadInfos: RawThreadInfos): { + +[id: string]: LegacyRawThreadInfo, +} { + Object.keys(rawThreadInfos).forEach(key => { + invariant( + !rawThreadInfos[key].minimallyEncoded, + `rawThreadInfos shouldn't be minimallyEncoded`, + ); + }); + + return (rawThreadInfos: any); +} + export { threadHasPermission, viewerIsMember, @@ -1822,4 +1836,5 @@ useRoleUserSurfacedPermissions, getThreadsToDeleteText, useUserProfileThreadInfo, + assertAllThreadInfosAreLegacy, }; diff --git a/native/redux/persist.js b/native/redux/persist.js --- a/native/redux/persist.js +++ b/native/redux/persist.js @@ -39,6 +39,7 @@ import { getContainingThreadID, getCommunity, + assertAllThreadInfosAreLegacy, } from 'lib/shared/thread-utils.js'; import { DEPRECATED_unshimMessageStore, @@ -73,6 +74,7 @@ import type { ClientDBThreadInfo, LegacyRawThreadInfo, + RawThreadInfo, } from 'lib/types/thread-types.js'; import { translateClientDBMessageInfoToRawMessageInfo, @@ -379,7 +381,7 @@ return state; } - const threadInfos: { [string]: LegacyRawThreadInfo } = {}; + const threadInfos: { [string]: RawThreadInfo } = {}; const stack = [...rootIDs]; while (stack.length > 0) { const threadID = stack.shift(); @@ -403,9 +405,12 @@ return { ...state, threadStore: { ...state.threadStore, threadInfos } }; }, [29]: (state: AppState) => { - const updatedThreadInfos = migrateThreadStoreForEditThreadPermissions( - state.threadStore.threadInfos, - ); + const legacyRawThreadInfos: { + +[id: string]: LegacyRawThreadInfo, + } = assertAllThreadInfosAreLegacy(state.threadStore.threadInfos); + + const updatedThreadInfos = + migrateThreadStoreForEditThreadPermissions(legacyRawThreadInfos); return { ...state,