[MM-62107] Remove the need to have the currently selected thread in the Unreads pane (#29876)
* [MM-62107] Remove the need to have the currently selected thread in the Unreads pane * Remove selected thread from Followed Threads as well if it's not followed --------- Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
291feba75c
Коммит
9ba9b646c3
@@ -57,8 +57,8 @@ const GlobalThreads = () => {
|
||||
const selectedThread = useSelector((state: GlobalState) => getThread(state, threadIdentifier));
|
||||
const selectedThreadId = useSelector(getSelectedThreadIdInCurrentTeam);
|
||||
const selectedPost = useSelector((state: GlobalState) => getPost(state, threadIdentifier!));
|
||||
const threadIds = useSelector((state: GlobalState) => getThreadOrderInCurrentTeam(state, selectedThread?.id), shallowEqual);
|
||||
const unreadThreadIds = useSelector((state: GlobalState) => getUnreadThreadOrderInCurrentTeam(state, selectedThread?.id), shallowEqual);
|
||||
const threadIds = useSelector((state: GlobalState) => getThreadOrderInCurrentTeam(state), shallowEqual);
|
||||
const unreadThreadIds = useSelector((state: GlobalState) => getUnreadThreadOrderInCurrentTeam(state), shallowEqual);
|
||||
const numUnread = counts?.total_unread_threads || 0;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -94,12 +94,8 @@ const GlobalThreads = () => {
|
||||
|
||||
const [isLoading, setLoading] = useState(isEmptyList);
|
||||
|
||||
const isOnlySelectedThreadInList = (list: string[]) => {
|
||||
return selectedThreadId && list.length === 1 && list[0] === selectedThreadId;
|
||||
};
|
||||
|
||||
const shouldLoadThreads = isEmpty(threadIds) || isOnlySelectedThreadInList(threadIds);
|
||||
const shouldLoadUnreadThreads = isEmpty(unreadThreadIds) || isOnlySelectedThreadInList(unreadThreadIds);
|
||||
const shouldLoadThreads = isEmpty(threadIds);
|
||||
const shouldLoadUnreadThreads = isEmpty(unreadThreadIds);
|
||||
|
||||
useEffect(() => {
|
||||
const promises = [];
|
||||
|
||||
@@ -104,22 +104,15 @@ export function makeGetThreadOrSynthetic(): (state: GlobalState, rootPost: Post)
|
||||
);
|
||||
}
|
||||
|
||||
export const getThreadOrderInCurrentTeam: (state: GlobalState, selectedThreadIdInTeam?: UserThread['id']) => Array<UserThread['id']> = createSelector(
|
||||
export const getThreadOrderInCurrentTeam: (state: GlobalState) => Array<UserThread['id']> = createSelector(
|
||||
'getThreadOrderInCurrentTeam',
|
||||
getThreadsInCurrentTeam,
|
||||
getThreads,
|
||||
(state: GlobalState, selectedThreadIdInTeam?: UserThread['id']) => selectedThreadIdInTeam,
|
||||
(
|
||||
threadsInTeam,
|
||||
threads,
|
||||
selectedThreadIdInTeam,
|
||||
) => {
|
||||
const ids = [...threadsInTeam.filter((id) => threads[id].is_following)];
|
||||
|
||||
if (selectedThreadIdInTeam && !ids.includes(selectedThreadIdInTeam)) {
|
||||
ids.push(selectedThreadIdInTeam);
|
||||
}
|
||||
|
||||
return sortByLastReply(ids, threads);
|
||||
},
|
||||
);
|
||||
@@ -145,26 +138,19 @@ export const getNewestThreadInTeam: (state: GlobalState, teamID: string,) => (Us
|
||||
|
||||
export const getUnreadThreadOrderInCurrentTeam: (
|
||||
state: GlobalState,
|
||||
selectedThreadIdInTeam?: UserThread['id'],
|
||||
) => Array<UserThread['id']> = createSelector(
|
||||
'getUnreadThreadOrderInCurrentTeam',
|
||||
getUnreadThreadsInCurrentTeam,
|
||||
getThreads,
|
||||
(state: GlobalState, selectedThreadIdInTeam?: UserThread['id']) => selectedThreadIdInTeam,
|
||||
(
|
||||
threadsInTeam,
|
||||
threads,
|
||||
selectedThreadIdInTeam,
|
||||
) => {
|
||||
const ids = threadsInTeam.filter((id) => {
|
||||
const thread = threads[id];
|
||||
return thread.is_following && (thread.unread_replies || thread.unread_mentions);
|
||||
});
|
||||
|
||||
if (selectedThreadIdInTeam && !ids.includes(selectedThreadIdInTeam)) {
|
||||
ids.push(selectedThreadIdInTeam);
|
||||
}
|
||||
|
||||
return sortByLastReply(ids, threads);
|
||||
},
|
||||
);
|
||||
|
||||
Ссылка в новой задаче
Block a user