diff --git a/lib/selectors/thread-selectors.js b/lib/selectors/thread-selectors.js --- a/lib/selectors/thread-selectors.js +++ b/lib/selectors/thread-selectors.js @@ -33,7 +33,6 @@ roleIsAdminRole, threadIsPending, getPendingThreadID, - pendingThreadType, } from '../shared/thread-utils.js'; import type { ClientAvatar, ClientEmojiAvatar } from '../types/avatar-types'; import type { EntryInfo } from '../types/entry-types.js'; @@ -49,7 +48,10 @@ threadTypeIsThick, threadTypeIsCommunityRoot, type ThreadType, + threadTypes, threadTypeIsSidebar, + threadTypeIsPrivate, + threadTypeIsPersonal, } from '../types/thread-types-enum.js'; import type { MixedRawThreadInfos, @@ -459,17 +461,38 @@ ) { continue; } + const actualMemberIDs = rawThreadInfo.members .filter(member => member.role) .map(member => member.id); + // In this function we're generating possible pending thread IDs that // could become `rawThreadInfos`. It is possible that a thick pending // thread becomes a thin thread, so we're including it twice in a map - // for each possible pending thread ID. - const possiblePendingThreadTypes = [ - pendingThreadType(actualMemberIDs.length - 1, 'thin'), - pendingThreadType(actualMemberIDs.length - 1, 'thick'), - ]; + let possiblePendingThreadTypes; + if (threadTypeIsPersonal(rawThreadInfo.type)) { + possiblePendingThreadTypes = [ + threadTypes.PERSONAL, + threadTypes.GENESIS_PERSONAL, + ]; + } else if (threadTypeIsPrivate(rawThreadInfo.type)) { + possiblePendingThreadTypes = [ + threadTypes.PRIVATE, + threadTypes.GENESIS_PRIVATE, + ]; + } else if (threadTypeIsSidebar(rawThreadInfo.type)) { + possiblePendingThreadTypes = [ + threadTypes.THICK_SIDEBAR, + threadTypes.SIDEBAR, + ]; + } else { + possiblePendingThreadTypes = [ + threadTypes.LOCAL, + threadTypes.COMMUNITY_SECRET_SUBTHREAD, + ]; + } + for (const type of possiblePendingThreadTypes) { const pendingThreadID = getPendingThreadID( type,