fix: showing first issue as default inbox state (#5147)

This commit is contained in:
Akshita Goyal 2024-07-17 18:46:40 +05:30 committed by GitHub
parent 4cb02a9270
commit 996192b9bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,8 @@
"use client";
import { FC, useCallback, useRef, useState } from "react";
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
@ -53,6 +54,7 @@ export const InboxSidebar: FC<IInboxSidebarProps> = observer((props) => {
} = useProjectInbox();
const router = useAppRouter();
const { inboxIssueId } = useParams();
const fetchNextPages = useCallback(() => {
if (!workspaceSlug || !projectId) return;
@ -62,6 +64,13 @@ export const InboxSidebar: FC<IInboxSidebarProps> = observer((props) => {
// page observer
useIntersectionObserver(containerRef, elementRef, fetchNextPages, "20%");
useEffect(() => {
if (inboxIssueId) return;
router.push(
`/${workspaceSlug}/projects/${projectId}/inbox?currentTab=${currentTab}&inboxIssueId=${filteredInboxIssueIds[0]}`
);
}, [filteredInboxIssueIds, currentTab, workspaceSlug, projectId, router, inboxIssueId]);
return (
<div className="bg-custom-background-100 flex-shrink-0 w-full h-full border-r border-custom-border-300 ">
<div className="relative w-full h-full flex flex-col overflow-hidden">