Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2860358
D13557.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D13557.diff
View Options
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,13 @@
threadTypeIsThick,
threadTypeIsCommunityRoot,
type ThreadType,
+ threadTypes,
threadTypeIsSidebar,
+ threadTypeIsPrivate,
+ threadTypeIsPersonal,
+ personalThreadTypes,
+ privateThreadTypes,
+ sidebarThreadTypes,
} from '../types/thread-types-enum.js';
import type {
MixedRawThreadInfos,
@@ -459,17 +464,29 @@
) {
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 = personalThreadTypes;
+ } else if (threadTypeIsPrivate(rawThreadInfo.type)) {
+ possiblePendingThreadTypes = privateThreadTypes;
+ } else if (threadTypeIsSidebar(rawThreadInfo.type)) {
+ possiblePendingThreadTypes = sidebarThreadTypes;
+ } else {
+ possiblePendingThreadTypes = [
+ threadTypes.LOCAL,
+ threadTypes.COMMUNITY_SECRET_SUBTHREAD,
+ ];
+ }
+
for (const type of possiblePendingThreadTypes) {
const pendingThreadID = getPendingThreadID(
type,
diff --git a/lib/types/thread-types-enum.js b/lib/types/thread-types-enum.js
--- a/lib/types/thread-types-enum.js
+++ b/lib/types/thread-types-enum.js
@@ -136,37 +136,40 @@
values(threadTypes),
);
-export const communityThreadTypes: $ReadOnlyArray<number> = Object.freeze([
- threadTypes.COMMUNITY_ROOT,
- threadTypes.COMMUNITY_ANNOUNCEMENT_ROOT,
- threadTypes.GENESIS,
-]);
-
-export const announcementThreadTypes: $ReadOnlyArray<number> = Object.freeze([
- threadTypes.GENESIS,
- threadTypes.COMMUNITY_ANNOUNCEMENT_ROOT,
- threadTypes.COMMUNITY_OPEN_ANNOUNCEMENT_SUBTHREAD,
- threadTypes.COMMUNITY_SECRET_ANNOUNCEMENT_SUBTHREAD,
-]);
-
-export const communitySubthreads: $ReadOnlyArray<number> = Object.freeze([
- threadTypes.COMMUNITY_OPEN_SUBTHREAD,
- threadTypes.COMMUNITY_OPEN_ANNOUNCEMENT_SUBTHREAD,
- threadTypes.COMMUNITY_SECRET_SUBTHREAD,
- threadTypes.COMMUNITY_SECRET_ANNOUNCEMENT_SUBTHREAD,
-]);
-
-export const sidebarThreadTypes: $ReadOnlyArray<number> = Object.freeze([
+export const communityThreadTypes: $ReadOnlyArray<ThinThreadType> =
+ Object.freeze([
+ threadTypes.COMMUNITY_ROOT,
+ threadTypes.COMMUNITY_ANNOUNCEMENT_ROOT,
+ threadTypes.GENESIS,
+ ]);
+
+export const announcementThreadTypes: $ReadOnlyArray<ThinThreadType> =
+ Object.freeze([
+ threadTypes.GENESIS,
+ threadTypes.COMMUNITY_ANNOUNCEMENT_ROOT,
+ threadTypes.COMMUNITY_OPEN_ANNOUNCEMENT_SUBTHREAD,
+ threadTypes.COMMUNITY_SECRET_ANNOUNCEMENT_SUBTHREAD,
+ ]);
+
+export const communitySubthreads: $ReadOnlyArray<ThinThreadType> =
+ Object.freeze([
+ threadTypes.COMMUNITY_OPEN_SUBTHREAD,
+ threadTypes.COMMUNITY_OPEN_ANNOUNCEMENT_SUBTHREAD,
+ threadTypes.COMMUNITY_SECRET_SUBTHREAD,
+ threadTypes.COMMUNITY_SECRET_ANNOUNCEMENT_SUBTHREAD,
+ ]);
+
+export const sidebarThreadTypes: $ReadOnlyArray<ThreadType> = Object.freeze([
threadTypes.SIDEBAR,
threadTypes.THICK_SIDEBAR,
]);
-export const personalThreadTypes: $ReadOnlyArray<number> = Object.freeze([
+export const personalThreadTypes: $ReadOnlyArray<ThreadType> = Object.freeze([
threadTypes.PERSONAL,
threadTypes.GENESIS_PERSONAL,
]);
-export const privateThreadTypes: $ReadOnlyArray<number> = Object.freeze([
+export const privateThreadTypes: $ReadOnlyArray<ThreadType> = Object.freeze([
threadTypes.PRIVATE,
threadTypes.GENESIS_PRIVATE,
]);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 2, 5:30 PM (21 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2219106
Default Alt Text
D13557.diff (4 KB)
Attached To
Mode
D13557: [lib] Match thread types in pendingToRealizedThreadIDsSelector
Attached
Detach File
Event Timeline
Log In to Comment