chore: issue comment reaction workflow and mutation update (#2537)
This commit is contained in:
parent
a6d741e784
commit
ca2da41dd2
8 changed files with 75 additions and 34 deletions
|
|
@ -12,6 +12,7 @@ import { render24HourFormatTime, renderLongDateFormat, timeAgo } from "helpers/d
|
|||
interface IssueActivityCard {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
issueId: string;
|
||||
user: any;
|
||||
issueComments: any;
|
||||
issueCommentUpdate: (comment: any) => void;
|
||||
|
|
@ -24,6 +25,7 @@ export const IssueActivityCard: FC<IssueActivityCard> = (props) => {
|
|||
const {
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
issueId,
|
||||
user,
|
||||
issueComments,
|
||||
issueCommentUpdate,
|
||||
|
|
@ -118,6 +120,7 @@ export const IssueActivityCard: FC<IssueActivityCard> = (props) => {
|
|||
<IssueCommentCard
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={projectId}
|
||||
issueId={issueId}
|
||||
user={user}
|
||||
comment={activityItem}
|
||||
onSubmit={issueCommentUpdate}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ type IIssueCommentCard = {
|
|||
showAccessSpecifier?: boolean;
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
issueId: string;
|
||||
user: any;
|
||||
issueCommentReactionCreate: (commentId: string, reaction: string) => void;
|
||||
issueCommentReactionRemove: (commentId: string, reaction: string) => void;
|
||||
|
|
@ -36,6 +37,7 @@ export const IssueCommentCard: React.FC<IIssueCommentCard> = (props) => {
|
|||
showAccessSpecifier = false,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
issueId,
|
||||
user,
|
||||
issueCommentReactionCreate,
|
||||
issueCommentReactionRemove,
|
||||
|
|
@ -157,6 +159,7 @@ export const IssueCommentCard: React.FC<IIssueCommentCard> = (props) => {
|
|||
<IssueCommentReaction
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={projectId}
|
||||
issueId={issueId}
|
||||
user={user}
|
||||
comment={comment}
|
||||
issueCommentReactionCreate={issueCommentReactionCreate}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ import { useMobxStore } from "lib/mobx/store-provider";
|
|||
import { RootStore } from "store/root";
|
||||
|
||||
interface IIssueCommentReaction {
|
||||
workspaceSlug: any;
|
||||
projectId: any;
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
issueId: string;
|
||||
user: any;
|
||||
|
||||
comment: any;
|
||||
|
|
@ -19,7 +20,8 @@ interface IIssueCommentReaction {
|
|||
}
|
||||
|
||||
export const IssueCommentReaction: FC<IIssueCommentReaction> = observer((props) => {
|
||||
const { workspaceSlug, projectId, user, comment, issueCommentReactionCreate, issueCommentReactionRemove } = props;
|
||||
const { workspaceSlug, projectId, issueId, user, comment, issueCommentReactionCreate, issueCommentReactionRemove } =
|
||||
props;
|
||||
|
||||
const { issueDetail: issueDetailStore }: RootStore = useMobxStore();
|
||||
|
||||
|
|
@ -32,15 +34,18 @@ export const IssueCommentReaction: FC<IIssueCommentReaction> = observer((props)
|
|||
};
|
||||
|
||||
useSWR(
|
||||
workspaceSlug && projectId && comment && comment?.id ? `ISSUE+PEEK_OVERVIEW_COMMENT_${comment?.id}` : null,
|
||||
workspaceSlug && projectId && issueId && comment && comment?.id
|
||||
? `ISSUE+PEEK_OVERVIEW_COMMENT_${comment?.id}`
|
||||
: null,
|
||||
() => {
|
||||
if (workspaceSlug && projectId && comment && comment.id) {
|
||||
issueDetailStore.fetchIssueCommentReactions(workspaceSlug, projectId, comment?.id);
|
||||
if (workspaceSlug && projectId && issueId && comment && comment.id) {
|
||||
issueDetailStore.fetchIssueCommentReactions(workspaceSlug, projectId, issueId, comment?.id);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const issueReactions = issueDetailStore?.getIssueCommentReactionsByCommentId(comment.id) || [];
|
||||
let issueReactions = issueDetailStore?.getIssueCommentReactions || null;
|
||||
issueReactions = issueReactions && comment.id ? issueReactions?.[comment.id] : [];
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { IssueCommentEditor } from "./comment-editor";
|
|||
interface IIssueComment {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
issueId: string;
|
||||
user: any;
|
||||
issueComments: any;
|
||||
issueCommentCreate: (comment: any) => void;
|
||||
|
|
@ -19,6 +20,7 @@ export const IssueComment: FC<IIssueComment> = (props) => {
|
|||
const {
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
issueId,
|
||||
user,
|
||||
issueComments,
|
||||
issueCommentCreate,
|
||||
|
|
@ -46,6 +48,7 @@ export const IssueComment: FC<IIssueComment> = (props) => {
|
|||
<IssueActivityCard
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={projectId}
|
||||
issueId={issueId}
|
||||
user={user}
|
||||
issueComments={issueComments}
|
||||
issueCommentUpdate={issueCommentUpdate}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export const IssueReaction: FC<IIssueReaction> = (props) => {
|
|||
|
||||
const handleReaction = (reaction: string) => {
|
||||
const isReactionAvailable =
|
||||
issueReactions[reaction].find((_reaction: any) => _reaction.actor === user?.id) ?? false;
|
||||
issueReactions?.[reaction].find((_reaction: any) => _reaction.actor === user?.id) ?? false;
|
||||
|
||||
if (isReactionAvailable) issueReactionRemove(reaction);
|
||||
else issueReactionCreate(reaction);
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
|
|||
issueDetailStore.removeIssueComment(workspaceSlug, projectId, issueId, commentId);
|
||||
|
||||
const issueCommentReactionCreate = (commentId: string, reaction: string) =>
|
||||
issueDetailStore.creationIssueCommentReaction(workspaceSlug, projectId, commentId, reaction);
|
||||
issueDetailStore.creationIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
|
||||
|
||||
const issueCommentReactionRemove = (commentId: string, reaction: string) =>
|
||||
issueDetailStore.removeIssueCommentReaction(workspaceSlug, projectId, commentId, reaction);
|
||||
issueDetailStore.removeIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
|
||||
|
||||
return (
|
||||
<IssueView
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
<IssueComment
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={projectId}
|
||||
issueId={issueId}
|
||||
user={user}
|
||||
issueComments={issueComments}
|
||||
issueCommentCreate={issueCommentCreate}
|
||||
|
|
@ -242,6 +243,7 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
<IssueComment
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={projectId}
|
||||
issueId={issueId}
|
||||
user={user}
|
||||
issueComments={issueComments}
|
||||
issueCommentCreate={issueCommentCreate}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue