Set focused comment based on url and visible thread id (#5992)
This commit is contained in:
parent
ba06d797de
commit
745927ffef
|
|
@ -6,12 +6,14 @@ import {
|
||||||
commentThreadsSelector,
|
commentThreadsSelector,
|
||||||
refCommentThreadsSelector,
|
refCommentThreadsSelector,
|
||||||
unpublishedCommentThreadSelector,
|
unpublishedCommentThreadSelector,
|
||||||
|
visibleCommentThreadSelector,
|
||||||
} from "../../selectors/commentsSelectors";
|
} from "../../selectors/commentsSelectors";
|
||||||
import {
|
import {
|
||||||
getCurrentApplicationId,
|
getCurrentApplicationId,
|
||||||
getCurrentPageId,
|
getCurrentPageId,
|
||||||
} from "selectors/editorSelectors";
|
} from "selectors/editorSelectors";
|
||||||
import { useLocation } from "react-router";
|
import { useLocation } from "react-router";
|
||||||
|
import { AppState } from "reducers";
|
||||||
|
|
||||||
// TODO refactor application comment threads by page id to optimise
|
// TODO refactor application comment threads by page id to optimise
|
||||||
// if lists turn out to be expensive
|
// if lists turn out to be expensive
|
||||||
|
|
@ -24,11 +26,18 @@ function InlinePageCommentPin({
|
||||||
}) {
|
}) {
|
||||||
const commentThread = useSelector(commentThreadsSelector(commentThreadId));
|
const commentThread = useSelector(commentThreadsSelector(commentThreadId));
|
||||||
const currentPageId = useSelector(getCurrentPageId);
|
const currentPageId = useSelector(getCurrentPageId);
|
||||||
|
const isVisibleCommentThread = useSelector(
|
||||||
|
(state: AppState) =>
|
||||||
|
visibleCommentThreadSelector(state) === commentThreadId,
|
||||||
|
);
|
||||||
|
|
||||||
if (commentThread && commentThread.pageId !== currentPageId) return null;
|
if (commentThread && commentThread.pageId !== currentPageId) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InlineCommentPin commentThreadId={commentThreadId} focused={focused} />
|
<InlineCommentPin
|
||||||
|
commentThreadId={commentThreadId}
|
||||||
|
focused={focused || isVisibleCommentThread}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ export const appCommentsFilter = (state: AppState) =>
|
||||||
export const showUnreadIndicator = (state: AppState) =>
|
export const showUnreadIndicator = (state: AppState) =>
|
||||||
state.ui.comments.unreadCommentThreadsCount > 0;
|
state.ui.comments.unreadCommentThreadsCount > 0;
|
||||||
|
|
||||||
export const visibleCommentThread = (state: AppState) =>
|
export const visibleCommentThreadSelector = (state: AppState) =>
|
||||||
state.ui.comments.visibleCommentThreadId;
|
state.ui.comments.visibleCommentThreadId;
|
||||||
|
|
||||||
export const isIntroCarouselVisibleSelector = (state: AppState) =>
|
export const isIntroCarouselVisibleSelector = (state: AppState) =>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user