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 @@ -79,21 +79,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'; @@ -1754,6 +1755,20 @@ ]); } +function assertAllThreadInfosAreLegacy(rawThreadInfos: RawThreadInfos): { + [id: string]: LegacyRawThreadInfo, +} { + return Object.fromEntries( + Object.entries(rawThreadInfos).map(([id, rawThreadInfo]) => { + invariant( + !rawThreadInfo.minimallyEncoded, + `rawThreadInfos shouldn't be minimallyEncoded`, + ); + return [id, rawThreadInfo]; + }), + ); +} + export { threadHasPermission, viewerIsMember, @@ -1820,4 +1835,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,