From f45c2d12fd6dd3ed18e733c0a5e141fb847350cb Mon Sep 17 00:00:00 2001 From: guru_sainath Date: Wed, 10 Apr 2024 16:08:31 +0530 Subject: [PATCH] [WEB-927, WEB-928] fix: inbox issue bug fixes and improvement (#4160) * chore: inbox duplicate issue modal improvement * chore: handled tab navigation in inbox issues and handled cross project inbox issues * chore: fetch inbox issue activity once the issue is updated in inbox issue * chore: disable duplicate inbox issue actions * chore: duplicate issue mutation in the inbox issue * chore: inbox create modal sidebar tab change updated * chore: multiple date selection in the inbox issue filters * chore: code refactor * chore: removed project dependancy on the inbox store structure --------- Co-authored-by: Anmol Singh Bhatia --- .../inbox/content/issue-properties.tsx | 18 ++++----- web/components/inbox/content/issue-root.tsx | 10 ++--- web/components/inbox/content/root.tsx | 6 +-- .../inbox/inbox-filter/filters/date.tsx | 8 +--- .../inbox/modals/create-issue-modal.tsx | 5 ++- .../inbox/modals/select-duplicate.tsx | 32 ++------------- .../inbox/sidebar/inbox-list-item.tsx | 5 ++- web/components/inbox/sidebar/root.tsx | 2 +- .../issues/issue-detail/main-content.tsx | 14 +++---- web/components/issues/issue-detail/root.tsx | 6 +-- .../issues/issue-detail/sidebar.tsx | 40 +++++++++---------- web/components/issues/peek-overview/root.tsx | 4 +- .../projects/[projectId]/inbox/index.tsx | 11 +++-- web/store/inbox/inbox-issue.store.ts | 15 +++++-- web/store/inbox/project-inbox.store.ts | 28 +++++++------ 15 files changed, 96 insertions(+), 108 deletions(-) diff --git a/web/components/inbox/content/issue-properties.tsx b/web/components/inbox/content/issue-properties.tsx index e80ec9fd2..670b7b1b8 100644 --- a/web/components/inbox/content/issue-properties.tsx +++ b/web/components/inbox/content/issue-properties.tsx @@ -17,12 +17,12 @@ type Props = { projectId: string; issue: Partial; issueOperations: TIssueOperations; - is_editable: boolean; + isEditable: boolean; duplicateIssueDetails: TInboxDuplicateIssueDetails | undefined; }; export const InboxIssueProperties: React.FC = observer((props) => { - const { workspaceSlug, projectId, issue, issueOperations, is_editable, duplicateIssueDetails } = props; + const { workspaceSlug, projectId, issue, issueOperations, isEditable, duplicateIssueDetails } = props; const router = useRouter(); // store hooks @@ -35,7 +35,7 @@ export const InboxIssueProperties: React.FC = observer((props) => {
Properties
-
+
{/* State */}
@@ -50,7 +50,7 @@ export const InboxIssueProperties: React.FC = observer((props) => { issue?.id && issueOperations.update(workspaceSlug, projectId, issue?.id, { state_id: val }) } projectId={projectId?.toString() ?? ""} - disabled={!is_editable} + disabled={!isEditable} buttonVariant="transparent-with-text" className="w-3/5 flex-grow group" buttonContainerClassName="w-full text-left" @@ -71,7 +71,7 @@ export const InboxIssueProperties: React.FC = observer((props) => { onChange={(val) => issue?.id && issueOperations.update(workspaceSlug, projectId, issue?.id, { assignee_ids: val }) } - disabled={!is_editable} + disabled={!isEditable} projectId={projectId?.toString() ?? ""} placeholder="Add assignees" multiple @@ -99,7 +99,7 @@ export const InboxIssueProperties: React.FC = observer((props) => { onChange={(val) => issue?.id && issueOperations.update(workspaceSlug, projectId, issue?.id, { priority: val }) } - disabled={!is_editable} + disabled={!isEditable} buttonVariant="border-with-text" className="w-3/5 flex-grow rounded px-2 hover:bg-custom-background-80" buttonContainerClassName="w-full text-left" @@ -108,7 +108,7 @@ export const InboxIssueProperties: React.FC = observer((props) => {
-
+
{/* Due Date */}
@@ -126,7 +126,7 @@ export const InboxIssueProperties: React.FC = observer((props) => { }) } minDate={minDate ?? undefined} - disabled={!is_editable} + disabled={!isEditable} buttonVariant="transparent-with-text" className="w-3/5 flex-grow group" buttonContainerClassName="w-full text-left" @@ -147,7 +147,7 @@ export const InboxIssueProperties: React.FC = observer((props) => { workspaceSlug={workspaceSlug} projectId={projectId} issueId={issue?.id} - disabled={!is_editable} + disabled={!isEditable} isInboxIssue onLabelUpdate={(val: string[]) => issue?.id && issueOperations.update(workspaceSlug, projectId, issue?.id, { label_ids: val }) diff --git a/web/components/inbox/content/issue-root.tsx b/web/components/inbox/content/issue-root.tsx index ec5604817..7edcc2644 100644 --- a/web/components/inbox/content/issue-root.tsx +++ b/web/components/inbox/content/issue-root.tsx @@ -22,14 +22,14 @@ type Props = { workspaceSlug: string; projectId: string; inboxIssue: IInboxIssueStore; - is_editable: boolean; + isEditable: boolean; isSubmitting: "submitting" | "submitted" | "saved"; setIsSubmitting: Dispatch>; }; export const InboxIssueMainContent: React.FC = observer((props) => { const router = useRouter(); - const { workspaceSlug, projectId, inboxIssue, is_editable, isSubmitting, setIsSubmitting } = props; + const { workspaceSlug, projectId, inboxIssue, isEditable, isSubmitting, setIsSubmitting } = props; // hooks const { currentUser } = useUser(); const { setShowAlert } = useReloadConfirmations(isSubmitting === "submitting"); @@ -126,7 +126,7 @@ export const InboxIssueMainContent: React.FC = observer((props) => { isSubmitting={isSubmitting} setIsSubmitting={(value) => setIsSubmitting(value)} issueOperations={issueOperations} - disabled={!is_editable} + disabled={!isEditable} value={issue.name} /> @@ -136,7 +136,7 @@ export const InboxIssueMainContent: React.FC = observer((props) => { issueId={issue.id} value={issueDescription} initialValue={issueDescription} - disabled={!is_editable} + disabled={!isEditable} issueOperations={issueOperations} setIsSubmitting={(value) => setIsSubmitting(value)} /> @@ -156,7 +156,7 @@ export const InboxIssueMainContent: React.FC = observer((props) => { projectId={projectId} issue={issue} issueOperations={issueOperations} - is_editable={is_editable} + isEditable={isEditable} duplicateIssueDetails={inboxIssue?.duplicate_issue_detail} /> diff --git a/web/components/inbox/content/root.tsx b/web/components/inbox/content/root.tsx index c15bf0863..9b5f94a48 100644 --- a/web/components/inbox/content/root.tsx +++ b/web/components/inbox/content/root.tsx @@ -32,11 +32,11 @@ export const InboxContentRoot: FC = observer((props) => { { revalidateOnFocus: false } ); - const is_editable = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; + const isEditable = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; if (!inboxIssue) return <>; - const isIssueAcceptedOrDeclined = [-1, 1].includes(inboxIssue.status); + const isIssueDisabled = [-1, 1, 2].includes(inboxIssue.status); return ( <> @@ -54,7 +54,7 @@ export const InboxContentRoot: FC = observer((props) => { workspaceSlug={workspaceSlug} projectId={projectId} inboxIssue={inboxIssue} - is_editable={is_editable && !isIssueAcceptedOrDeclined} + isEditable={isEditable && !isIssueDisabled} isSubmitting={isSubmitting} setIsSubmitting={setIsSubmitting} /> diff --git a/web/components/inbox/inbox-filter/filters/date.tsx b/web/components/inbox/inbox-filter/filters/date.tsx index 50e9b71b0..aee188be8 100644 --- a/web/components/inbox/inbox-filter/filters/date.tsx +++ b/web/components/inbox/inbox-filter/filters/date.tsx @@ -38,12 +38,6 @@ export const FilterDate: FC = observer((props) => { const handleFilterValue = (value: string): string[] => (filterValue?.includes(value) ? [] : uniq(concat(value))); - const handleCustomFilterValue = (value: string[]): string[] => { - const finalOptions: string[] = [...filterValue]; - value.forEach((v) => (finalOptions?.includes(v) ? [] : finalOptions.push(v))); - return uniq(finalOptions); - }; - const isCustomDateSelected = () => { const isValidDateSelected = filterValue?.filter((f) => isDate(f.split(";")[0])) || []; return isValidDateSelected.length > 0 ? true : false; @@ -64,7 +58,7 @@ export const FilterDate: FC = observer((props) => { setIsDateFilterModalOpen(false)} isOpen={isDateFilterModalOpen} - onSelect={(val) => handleInboxIssueFilters(filterKey, handleCustomFilterValue(val))} + onSelect={(val) => handleInboxIssueFilters(filterKey, val)} title="Created date" /> )} diff --git a/web/components/inbox/modals/create-issue-modal.tsx b/web/components/inbox/modals/create-issue-modal.tsx index 4c22f8348..9ec5cba1e 100644 --- a/web/components/inbox/modals/create-issue-modal.tsx +++ b/web/components/inbox/modals/create-issue-modal.tsx @@ -52,7 +52,7 @@ export const CreateInboxIssueModal: React.FC = observer((props) => { const workspaceStore = useWorkspace(); const workspaceId = workspaceStore.getWorkspaceBySlug(workspaceSlug as string)?.id as string; // store hooks - const { createInboxIssue } = useProjectInbox(); + const { createInboxIssue, handleCurrentTab } = useProjectInbox(); const { config: { envConfig }, } = useApplication(); @@ -79,7 +79,8 @@ export const CreateInboxIssueModal: React.FC = observer((props) => { await createInboxIssue(workspaceSlug.toString(), projectId.toString(), formData) .then((res) => { if (!createMore) { - router.push(`/${workspaceSlug}/projects/${projectId}/inbox/?inboxIssueId=${res?.issue?.id}`); + router.push(`/${workspaceSlug}/projects/${projectId}/inbox/?currentTab=open&inboxIssueId=${res?.issue?.id}`); + handleCurrentTab("open"); handleClose(); } else { reset(defaultValues); diff --git a/web/components/inbox/modals/select-duplicate.tsx b/web/components/inbox/modals/select-duplicate.tsx index 2df720dd8..34418bdd3 100644 --- a/web/components/inbox/modals/select-duplicate.tsx +++ b/web/components/inbox/modals/select-duplicate.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import React, { useState } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; import { Search } from "lucide-react"; @@ -7,7 +7,7 @@ import { Combobox, Dialog, Transition } from "@headlessui/react"; // icons // components // ui -import { Button, TOAST_TYPE, setToast } from "@plane/ui"; +import { TOAST_TYPE, setToast } from "@plane/ui"; import { EmptyState } from "@/components/empty-state"; // services // constants @@ -29,7 +29,6 @@ export const SelectDuplicateInboxIssueModal: React.FC = (props) => { const { isOpen, onClose, onSubmit, value } = props; const [query, setQuery] = useState(""); - const [selectedItem, setSelectedItem] = useState(""); const router = useRouter(); const { workspaceSlug, projectId, issueId } = router.query; @@ -48,18 +47,11 @@ export const SelectDuplicateInboxIssueModal: React.FC = (props) => { : null ); - useEffect(() => { - if (!value) { - setSelectedItem(""); - return; - } else setSelectedItem(value); - }, [value]); - const handleClose = () => { onClose(); }; - const handleSubmit = () => { + const handleSubmit = (selectedItem: string) => { if (!selectedItem || selectedItem.length === 0) return setToast({ title: "Error", @@ -99,12 +91,7 @@ export const SelectDuplicateInboxIssueModal: React.FC = (props) => { leaveTo="opacity-0 scale-95" > - { - setSelectedItem(value); - }} - > +
= (props) => { )} - - {filteredIssues.length > 0 && ( -
- - -
- )}
diff --git a/web/components/inbox/sidebar/inbox-list-item.tsx b/web/components/inbox/sidebar/inbox-list-item.tsx index 262d1e6c0..837a6992f 100644 --- a/web/components/inbox/sidebar/inbox-list-item.tsx +++ b/web/components/inbox/sidebar/inbox-list-item.tsx @@ -9,7 +9,7 @@ import { InboxIssueStatus } from "@/components/inbox"; import { cn } from "@/helpers/common.helper"; import { renderFormattedDate } from "@/helpers/date-time.helper"; // hooks -import { useLabel } from "@/hooks/store"; +import { useLabel, useProjectInbox } from "@/hooks/store"; import { usePlatformOS } from "@/hooks/use-platform-os"; // store import { IInboxIssueStore } from "@/store/inbox/inbox-issue.store"; @@ -27,6 +27,7 @@ export const InboxIssueListItem: FC = observer((props) const router = useRouter(); const { inboxIssueId } = router.query; // store + const { currentTab } = useProjectInbox(); const { projectLabels } = useLabel(); const { isMobile } = usePlatformOS(); const issue = inboxIssue.issue; @@ -54,7 +55,7 @@ export const InboxIssueListItem: FC = observer((props) handleIssueRedirection(e, issue.id)} >
= observer((props) => { )} onClick={() => { if (currentTab != option?.key) handleCurrentTab(option?.key); - router.push(`/${workspaceSlug}/projects/${projectId}/inbox`); + router.push(`/${workspaceSlug}/projects/${projectId}/inbox?currentTab=${option?.key}`); }} >
{option?.label}
diff --git a/web/components/issues/issue-detail/main-content.tsx b/web/components/issues/issue-detail/main-content.tsx index 241c96109..28e01fd1e 100644 --- a/web/components/issues/issue-detail/main-content.tsx +++ b/web/components/issues/issue-detail/main-content.tsx @@ -21,11 +21,11 @@ type Props = { projectId: string; issueId: string; issueOperations: TIssueOperations; - is_editable: boolean; + isEditable: boolean; }; export const IssueMainContent: React.FC = observer((props) => { - const { workspaceSlug, projectId, issueId, issueOperations, is_editable } = props; + const { workspaceSlug, projectId, issueId, issueOperations, isEditable } = props; // states const [isSubmitting, setIsSubmitting] = useState<"submitting" | "submitted" | "saved">("saved"); // hooks @@ -90,7 +90,7 @@ export const IssueMainContent: React.FC = observer((props) => { isSubmitting={isSubmitting} setIsSubmitting={(value) => setIsSubmitting(value)} issueOperations={issueOperations} - disabled={!is_editable} + disabled={!isEditable} value={issue.name} /> @@ -100,7 +100,7 @@ export const IssueMainContent: React.FC = observer((props) => { issueId={issue.id} value={issueDescription} initialValue={issueDescription} - disabled={!is_editable} + disabled={!isEditable} issueOperations={issueOperations} setIsSubmitting={(value) => setIsSubmitting(value)} /> @@ -120,7 +120,7 @@ export const IssueMainContent: React.FC = observer((props) => { projectId={projectId} parentIssueId={issueId} currentUser={currentUser} - disabled={!is_editable} + disabled={!isEditable} /> )}
@@ -129,10 +129,10 @@ export const IssueMainContent: React.FC = observer((props) => { workspaceSlug={workspaceSlug} projectId={projectId} issueId={issueId} - disabled={!is_editable} + disabled={!isEditable} /> - + ); }); diff --git a/web/components/issues/issue-detail/root.tsx b/web/components/issues/issue-detail/root.tsx index fdd848a2d..46f5dd145 100644 --- a/web/components/issues/issue-detail/root.tsx +++ b/web/components/issues/issue-detail/root.tsx @@ -340,7 +340,7 @@ export const IssueDetailRoot: FC = observer((props) => { // issue details const issue = getIssueById(issueId); // checking if issue is editable, based on user role - const is_editable = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; + const isEditable = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; return ( <> @@ -362,7 +362,7 @@ export const IssueDetailRoot: FC = observer((props) => { projectId={projectId} issueId={issueId} issueOperations={issueOperations} - is_editable={!is_archived && is_editable} + isEditable={!is_archived && isEditable} />
= observer((props) => { issueId={issueId} issueOperations={issueOperations} is_archived={is_archived} - is_editable={!is_archived && is_editable} + isEditable={!is_archived && isEditable} />
diff --git a/web/components/issues/issue-detail/sidebar.tsx b/web/components/issues/issue-detail/sidebar.tsx index ce5b54770..80259dada 100644 --- a/web/components/issues/issue-detail/sidebar.tsx +++ b/web/components/issues/issue-detail/sidebar.tsx @@ -69,11 +69,11 @@ type Props = { issueId: string; issueOperations: TIssueOperations; is_archived: boolean; - is_editable: boolean; + isEditable: boolean; }; export const IssueDetailsSidebar: React.FC = observer((props) => { - const { workspaceSlug, projectId, issueId, issueOperations, is_archived, is_editable } = props; + const { workspaceSlug, projectId, issueId, issueOperations, is_archived, isEditable } = props; // states const [deleteIssueModal, setDeleteIssueModal] = useState(false); const [archiveIssueModal, setArchiveIssueModal] = useState(false); @@ -116,7 +116,7 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { const projectDetails = getProjectById(issue.project_id); const stateDetails = getStateById(issue.state_id); // auth - const isArchivingAllowed = !is_archived && issueOperations.archive && is_editable; + const isArchivingAllowed = !is_archived && issueOperations.archive && isEditable; const isInArchivableGroup = !!stateDetails && [STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateDetails?.group); @@ -179,7 +179,7 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { )} - {is_editable && ( + {isEditable && (
@@ -440,7 +440,7 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { projectId={projectId} issueId={issueId} relationKey="duplicate" - disabled={!is_editable} + disabled={!isEditable} />
@@ -454,7 +454,7 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { workspaceSlug={workspaceSlug} projectId={projectId} issueId={issueId} - disabled={!is_editable} + disabled={!isEditable} />
@@ -464,7 +464,7 @@ export const IssueDetailsSidebar: React.FC = observer((props) => { workspaceSlug={workspaceSlug} projectId={projectId} issueId={issueId} - disabled={!is_editable} + disabled={!isEditable} />
diff --git a/web/components/issues/peek-overview/root.tsx b/web/components/issues/peek-overview/root.tsx index 4d85bd73c..2ddc923a0 100644 --- a/web/components/issues/peek-overview/root.tsx +++ b/web/components/issues/peek-overview/root.tsx @@ -372,7 +372,7 @@ export const IssuePeekOverview: FC = observer((props) => { const currentProjectRole = currentWorkspaceAllProjectsRole?.[peekIssue?.projectId]; // Check if issue is editable, based on user role - const is_editable = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; + const isEditable = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; const isLoading = !issue || loader ? true : false; return ( @@ -382,7 +382,7 @@ export const IssuePeekOverview: FC = observer((props) => { issueId={peekIssue.issueId} isLoading={isLoading} is_archived={is_archived} - disabled={!is_editable} + disabled={!isEditable} issueOperations={issueOperations} /> ); diff --git a/web/pages/[workspaceSlug]/projects/[projectId]/inbox/index.tsx b/web/pages/[workspaceSlug]/projects/[projectId]/inbox/index.tsx index 84205776f..89e5c1022 100644 --- a/web/pages/[workspaceSlug]/projects/[projectId]/inbox/index.tsx +++ b/web/pages/[workspaceSlug]/projects/[projectId]/inbox/index.tsx @@ -1,4 +1,4 @@ -import { ReactElement } from "react"; +import { ReactElement, useEffect } from "react"; import { observer } from "mobx-react"; import { useRouter } from "next/router"; // components @@ -9,7 +9,7 @@ import { InboxIssueRoot } from "@/components/inbox"; // constants import { EmptyStateType } from "@/constants/empty-state"; // hooks -import { useProject } from "@/hooks/store"; +import { useProject, useProjectInbox } from "@/hooks/store"; // layouts import { AppLayout } from "@/layouts/app-layout"; // types @@ -18,9 +18,10 @@ import { NextPageWithLayout } from "@/lib/types"; const ProjectInboxPage: NextPageWithLayout = observer(() => { /// router const router = useRouter(); - const { workspaceSlug, projectId, inboxIssueId } = router.query; + const { workspaceSlug, projectId, currentTab: navigationTab, inboxIssueId } = router.query; // hooks const { currentProjectDetails } = useProject(); + const { currentTab, handleCurrentTab } = useProjectInbox(); if (!workspaceSlug || !projectId) return <>; @@ -38,6 +39,10 @@ const ProjectInboxPage: NextPageWithLayout = observer(() => { // derived values const pageTitle = currentProjectDetails?.name ? `${currentProjectDetails?.name} - Inbox` : "Plane - Inbox"; + useEffect(() => { + if (navigationTab && currentTab != navigationTab) handleCurrentTab(navigationTab === "open" ? "open" : "closed"); + }, [currentTab, navigationTab, handleCurrentTab]); + return (
diff --git a/web/store/inbox/inbox-issue.store.ts b/web/store/inbox/inbox-issue.store.ts index 2e9a95266..c42740cc1 100644 --- a/web/store/inbox/inbox-issue.store.ts +++ b/web/store/inbox/inbox-issue.store.ts @@ -1,9 +1,10 @@ import set from "lodash/set"; import { makeObservable, observable, runInAction, action } from "mobx"; -// services -// types import { TIssue, TInboxIssue, TInboxIssueStatus, TInboxDuplicateIssueDetails } from "@plane/types"; +// services import { InboxIssueService } from "@/services/inbox"; +// root store +import { RootStore } from "@/store/root.store"; export interface IInboxIssueStore { isLoading: boolean; @@ -36,7 +37,7 @@ export class InboxIssueStore implements IInboxIssueStore { // services inboxIssueService; - constructor(workspaceSlug: string, projectId: string, data: TInboxIssue) { + constructor(workspaceSlug: string, projectId: string, data: TInboxIssue, private store: RootStore) { this.id = data.id; this.status = data.status; this.issue = data?.issue; @@ -90,10 +91,14 @@ export class InboxIssueStore implements IInboxIssueStore { if (!this.issue.id) return; set(this, "status", inboxStatus); set(this, "duplicate_to", issueId); - await this.inboxIssueService.update(this.workspaceSlug, this.projectId, this.issue.id, { + const issueResponse = await this.inboxIssueService.update(this.workspaceSlug, this.projectId, this.issue.id, { status: inboxStatus, duplicate_to: issueId, }); + runInAction(() => { + this.duplicate_to = issueResponse.duplicate_to; + this.duplicate_issue_detail = issueResponse.duplicate_issue_detail; + }); } catch { runInAction(() => { set(this, "status", previousData.status); @@ -133,6 +138,8 @@ export class InboxIssueStore implements IInboxIssueStore { set(inboxIssue, issueKey, issue[issueKey]); }); await this.inboxIssueService.updateIssue(this.workspaceSlug, this.projectId, this.issue.id, issue); + // fetching activity + await this.store.issue.issueDetail.fetchActivities(this.workspaceSlug, this.projectId, this.issue.id); } catch { Object.keys(issue).forEach((key) => { const issueKey = key as keyof TIssue; diff --git a/web/store/inbox/project-inbox.store.ts b/web/store/inbox/project-inbox.store.ts index 43a1a229a..3ac10acd8 100644 --- a/web/store/inbox/project-inbox.store.ts +++ b/web/store/inbox/project-inbox.store.ts @@ -29,7 +29,7 @@ export interface IProjectInboxStore { inboxFilters: Partial; inboxSorting: Partial; inboxIssuePaginationInfo: TInboxIssuePaginationInfo | undefined; - inboxIssues: Record; + inboxIssues: Record; // issue_id -> IInboxIssueStore // computed getAppliedFiltersCount: number; inboxIssuesArray: IInboxIssueStore[]; @@ -177,8 +177,6 @@ export class ProjectInboxStore implements IProjectInboxStore { set(this, "inboxFilters", undefined); set(this, ["inboxSorting", "order_by"], "issue__created_at"); set(this, ["inboxSorting", "sort_by"], "desc"); - set(this, ["inboxIssues"], {}); - set(this, ["inboxIssuePaginationInfo"], undefined); if (tab === "closed") set(this, ["inboxFilters", "status"], [-1, 1, 2]); else set(this, ["inboxFilters", "status"], [-2]); const { workspaceSlug, projectId } = this.store.app.router; @@ -187,16 +185,12 @@ export class ProjectInboxStore implements IProjectInboxStore { handleInboxIssueFilters = (key: T, value: TInboxIssueFilter[T]) => { set(this.inboxFilters, key, value); - set(this, ["inboxIssues"], {}); - set(this, ["inboxIssuePaginationInfo"], undefined); const { workspaceSlug, projectId } = this.store.app.router; if (workspaceSlug && projectId) this.fetchInboxIssues(workspaceSlug, projectId, "filter-loading"); }; handleInboxIssueSorting = (key: T, value: TInboxIssueSorting[T]) => { set(this.inboxSorting, key, value); - set(this, ["inboxIssues"], {}); - set(this, ["inboxIssuePaginationInfo"], undefined); const { workspaceSlug, projectId } = this.store.app.router; if (workspaceSlug && projectId) this.fetchInboxIssues(workspaceSlug, projectId, "filter-loading"); }; @@ -210,6 +204,8 @@ export class ProjectInboxStore implements IProjectInboxStore { try { if (loadingType) this.isLoading = loadingType; else if (Object.keys(this.inboxIssues).length === 0) this.isLoading = "init-loading"; + set(this, ["inboxIssues"], {}); + set(this, ["inboxIssuePaginationInfo"], undefined); const queryParams = this.inboxIssueQueryParams( this.inboxFilters, @@ -225,7 +221,11 @@ export class ProjectInboxStore implements IProjectInboxStore { if (results && results.length > 0) results.forEach((value: TInboxIssue) => { if (this.getIssueInboxByIssueId(value?.issue?.id) === undefined) - set(this.inboxIssues, value?.issue?.id, new InboxIssueStore(workspaceSlug, projectId, value)); + set( + this.inboxIssues, + [value?.issue?.id], + new InboxIssueStore(workspaceSlug, projectId, value, this.store) + ); }); }); } catch (error) { @@ -267,7 +267,11 @@ export class ProjectInboxStore implements IProjectInboxStore { if (results && results.length > 0) results.forEach((value: TInboxIssue) => { if (this.getIssueInboxByIssueId(value?.issue?.id) === undefined) - set(this.inboxIssues, value?.issue?.id, new InboxIssueStore(workspaceSlug, projectId, value)); + set( + this.inboxIssues, + [value?.issue?.id], + new InboxIssueStore(workspaceSlug, projectId, value, this.store) + ); }); }); } else set(this, ["inboxIssuePaginationInfo", "next_page_results"], false); @@ -302,7 +306,7 @@ export class ProjectInboxStore implements IProjectInboxStore { // fetching comments await this.store.issue.issueDetail.fetchComments(workspaceSlug, projectId, issueId); runInAction(() => { - set(this.inboxIssues, issueId, new InboxIssueStore(workspaceSlug, projectId, inboxIssue)); + set(this.inboxIssues, [issueId], new InboxIssueStore(workspaceSlug, projectId, inboxIssue, this.store)); }); this.isLoading = undefined; } @@ -325,8 +329,8 @@ export class ProjectInboxStore implements IProjectInboxStore { runInAction(() => { set( this.inboxIssues, - inboxIssueResponse?.issue?.id, - new InboxIssueStore(workspaceSlug, projectId, inboxIssueResponse) + [inboxIssueResponse?.issue?.id], + new InboxIssueStore(workspaceSlug, projectId, inboxIssueResponse, this.store) ); set( this,