diff --git a/web/core/components/inbox/root.tsx b/web/core/components/inbox/root.tsx index 5913f69fce..5d5617bb39 100644 --- a/web/core/components/inbox/root.tsx +++ b/web/core/components/inbox/root.tsx @@ -34,7 +34,12 @@ export const InboxIssueRoot: FC = observer((props) => { if (navigationTab && navigationTab !== currentTab) { handleCurrentTab(workspaceSlug, projectId, navigationTab); } else { - fetchInboxIssues(workspaceSlug.toString(), projectId.toString(), undefined, navigationTab); + fetchInboxIssues( + workspaceSlug.toString(), + projectId.toString(), + undefined, + navigationTab || EInboxIssueCurrentTab.OPEN + ); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [inboxAccessible, workspaceSlug, projectId]); @@ -77,6 +82,7 @@ export const InboxIssueRoot: FC = observer((props) => { setIsMobileSidebar={setIsMobileSidebar} workspaceSlug={workspaceSlug.toString()} projectId={projectId.toString()} + inboxIssueId={inboxIssueId} /> diff --git a/web/core/components/inbox/sidebar/root.tsx b/web/core/components/inbox/sidebar/root.tsx index 2ee8552431..58f49a46cf 100644 --- a/web/core/components/inbox/sidebar/root.tsx +++ b/web/core/components/inbox/sidebar/root.tsx @@ -2,7 +2,6 @@ import { FC, useCallback, useEffect, useRef, useState } from "react"; import { observer } from "mobx-react"; -import { useParams } from "next/navigation"; import { TInboxIssueCurrentTab } from "@plane/types"; import { Loader } from "@plane/ui"; // components @@ -22,6 +21,7 @@ import { useIntersectionObserver } from "@/hooks/use-intersection-observer"; type IInboxSidebarProps = { workspaceSlug: string; projectId: string; + inboxIssueId: string | undefined; setIsMobileSidebar: (value: boolean) => void; }; @@ -37,7 +37,7 @@ const tabNavigationOptions: { key: TInboxIssueCurrentTab; label: string }[] = [ ]; export const InboxSidebar: FC = observer((props) => { - const { workspaceSlug, projectId, setIsMobileSidebar } = props; + const { workspaceSlug, projectId, inboxIssueId, setIsMobileSidebar } = props; // ref const containerRef = useRef(null); const [elementRef, setElementRef] = useState(null); @@ -54,7 +54,6 @@ export const InboxSidebar: FC = observer((props) => { } = useProjectInbox(); const router = useAppRouter(); - const { inboxIssueId } = useParams(); const fetchNextPages = useCallback(() => { if (!workspaceSlug || !projectId) return; @@ -65,11 +64,14 @@ export const InboxSidebar: FC = observer((props) => { useIntersectionObserver(containerRef, elementRef, fetchNextPages, "20%"); useEffect(() => { - if (inboxIssueId) return; - router.push( - `/${workspaceSlug}/projects/${projectId}/inbox?currentTab=${currentTab}&inboxIssueId=${filteredInboxIssueIds[0]}` - ); - }, []); + if (workspaceSlug && projectId && currentTab && filteredInboxIssueIds.length > 0) { + if (inboxIssueId === undefined) { + router.push( + `/${workspaceSlug}/projects/${projectId}/inbox?currentTab=${currentTab}&inboxIssueId=${filteredInboxIssueIds[0]}` + ); + } + } + }, [currentTab, filteredInboxIssueIds, inboxIssueId, projectId, router, workspaceSlug]); return (