From a4c40ce25ebd2c97a19fb4e4e17404c1e055e331 Mon Sep 17 00:00:00 2001 From: Hemachandar <132386067+hmacr@users.noreply.github.com> Date: Sat, 16 Nov 2024 07:44:30 +0530 Subject: [PATCH] show resolved view when a resolved comment is opened from notif email (#7959) * show resolved view when a resolved comment is opened from notif email * check and replace state --- app/scenes/Document/components/Editor.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/scenes/Document/components/Editor.tsx b/app/scenes/Document/components/Editor.tsx index f9811dd1bf..17e0201c71 100644 --- a/app/scenes/Document/components/Editor.tsx +++ b/app/scenes/Document/components/Editor.tsx @@ -27,6 +27,7 @@ import useCurrentTeam from "~/hooks/useCurrentTeam"; import useCurrentUser from "~/hooks/useCurrentUser"; import useFocusedComment from "~/hooks/useFocusedComment"; import usePolicy from "~/hooks/usePolicy"; +import useQuery from "~/hooks/useQuery"; import useStores from "~/hooks/useStores"; import { documentHistoryPath, @@ -81,6 +82,7 @@ function DocumentEditor(props: Props, ref: React.RefObject) { const user = useCurrentUser({ rejectOnEmpty: false }); const team = useCurrentTeam({ rejectOnEmpty: false }); const history = useHistory(); + const params = useQuery(); const { document, onChangeTitle, @@ -103,9 +105,20 @@ function DocumentEditor(props: Props, ref: React.RefObject) { React.useEffect(() => { if (focusedComment) { + const viewingResolved = params.get("resolved") === ""; + if ( + (focusedComment.isResolved && !viewingResolved) || + (!focusedComment.isResolved && viewingResolved) + ) { + history.replace({ + search: focusedComment.isResolved ? "resolved=" : "", + pathname: location.pathname, + state: { commentId: focusedComment.id }, + }); + } ui.expandComments(document.id); } - }, [focusedComment, ui, document.id]); + }, [focusedComment, ui, document.id, history, params]); // Save document when blurring title, but delay so that if clicking on a // button this is allowed to execute first.