fix: inbox issue activity not being rendered (#2487)

This commit is contained in:
Aaryan Khandelwal 2023-10-19 14:53:29 +05:30 committed by GitHub
parent 861ff4ae94
commit 85a471305a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View File

@ -69,6 +69,7 @@ export const AnalyticsTable: React.FC<Props> = ({ analytics, barGraphData, param
}`} }`}
> >
{params.x_axis === "priority" ? ( {params.x_axis === "priority" ? (
// TODO: incorrect priority icon being rendered
<PriorityIcon priority={item.name as TIssuePriorities} /> <PriorityIcon priority={item.name as TIssuePriorities} />
) : ( ) : (
<span <span

View File

@ -1,13 +1,13 @@
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useSWR, { mutate } from "swr"; import useSWR, { mutate } from "swr";
import { observer } from "mobx-react-lite";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { AddComment, IssueActivitySection } from "components/issues"; import { AddComment, IssueActivitySection } from "components/issues";
// services // services
import { IssueService, IssueCommentService } from "services/issue"; import { IssueService, IssueCommentService } from "services/issue";
// hooks // hooks
import useUser from "hooks/use-user";
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
// types // types
import { IIssue, IIssueComment } from "types"; import { IIssue, IIssueComment } from "types";
@ -20,23 +20,25 @@ type Props = { issueDetails: IIssue };
const issueService = new IssueService(); const issueService = new IssueService();
const issueCommentService = new IssueCommentService(); const issueCommentService = new IssueCommentService();
export const InboxIssueActivity: React.FC<Props> = ({ issueDetails }) => { export const InboxIssueActivity: React.FC<Props> = observer(({ issueDetails }) => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, inboxIssueId } = router.query; const { workspaceSlug, projectId, inboxIssueId } = router.query;
const { user: userStore } = useMobxStore();
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
const { user } = useUser();
const { data: issueActivity, mutate: mutateIssueActivity } = useSWR( const { data: issueActivity, mutate: mutateIssueActivity } = useSWR(
workspaceSlug && projectId && inboxIssueId ? PROJECT_ISSUES_ACTIVITY(inboxIssueId.toString()) : null, workspaceSlug && projectId && issueDetails ? PROJECT_ISSUES_ACTIVITY(issueDetails.id) : null,
workspaceSlug && projectId && inboxIssueId workspaceSlug && projectId && issueDetails
? () => issueService.getIssueActivities(workspaceSlug.toString(), projectId.toString(), inboxIssueId.toString()) ? () => issueService.getIssueActivities(workspaceSlug.toString(), projectId.toString(), issueDetails.id)
: null : null
); );
const user = userStore.currentUser;
const handleCommentUpdate = async (commentId: string, data: Partial<IIssueComment>) => { const handleCommentUpdate = async (commentId: string, data: Partial<IIssueComment>) => {
if (!workspaceSlug || !projectId || !inboxIssueId) return; if (!workspaceSlug || !projectId || !inboxIssueId || !user) return;
await issueCommentService await issueCommentService
.patchIssueComment(workspaceSlug as string, projectId as string, inboxIssueId as string, commentId, data, user) .patchIssueComment(workspaceSlug as string, projectId as string, inboxIssueId as string, commentId, data, user)
@ -44,7 +46,7 @@ export const InboxIssueActivity: React.FC<Props> = ({ issueDetails }) => {
}; };
const handleCommentDelete = async (commentId: string) => { const handleCommentDelete = async (commentId: string) => {
if (!workspaceSlug || !projectId || !inboxIssueId) return; if (!workspaceSlug || !projectId || !inboxIssueId || !user) return;
mutateIssueActivity((prevData: any) => prevData?.filter((p: any) => p.id !== commentId), false); mutateIssueActivity((prevData: any) => prevData?.filter((p: any) => p.id !== commentId), false);
@ -54,7 +56,7 @@ export const InboxIssueActivity: React.FC<Props> = ({ issueDetails }) => {
}; };
const handleAddComment = async (formData: IIssueComment) => { const handleAddComment = async (formData: IIssueComment) => {
if (!workspaceSlug || !issueDetails) return; if (!workspaceSlug || !issueDetails || !user) return;
await issueCommentService await issueCommentService
.createIssueComment(workspaceSlug.toString(), issueDetails.project, issueDetails.id, formData, user) .createIssueComment(workspaceSlug.toString(), issueDetails.project, issueDetails.id, formData, user)
@ -81,4 +83,4 @@ export const InboxIssueActivity: React.FC<Props> = ({ issueDetails }) => {
<AddComment onSubmit={handleAddComment} /> <AddComment onSubmit={handleAddComment} />
</div> </div>
); );
}; });