Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion web/core/components/inbox/content/inbox-issue-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ export const InboxIssueActionsHeader: FC<TInboxIssueActionsHeader> = observer((p
};

useEffect(() => {
if (isSubmitting === "submitting") return;
if (!isNotificationEmbed) document.addEventListener("keydown", onKeyDown);
return () => {
if (!isNotificationEmbed) document.removeEventListener("keydown", onKeyDown);
};
}, [onKeyDown, isNotificationEmbed]);
}, [onKeyDown, isNotificationEmbed, isSubmitting]);

if (!inboxIssue) return null;

Expand Down
2 changes: 1 addition & 1 deletion web/core/components/inbox/content/issue-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const InboxIssueMainContent: React.FC<Props> = observer((props) => {
},
update: async (_workspaceSlug: string, _projectId: string, _issueId: string, data: Partial<TIssue>) => {
try {
await inboxIssue.updateIssue({ ...data, id: _issueId });
await inboxIssue.updateIssue(data);
captureIssueEvent({
eventName: "Inbox issue updated",
payload: { ...data, state: "SUCCESS", element: "Inbox" },
Expand Down
25 changes: 11 additions & 14 deletions web/core/components/issues/description-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((p
});

const handleDescriptionFormSubmit = useCallback(
async (formData: Partial<TIssue>, _issueId: string) => {
await issueOperations.update(workspaceSlug, projectId, _issueId, {
async (formData: Partial<TIssue>) => {
await issueOperations.update(workspaceSlug, projectId, issueId, {
description_html: formData.description_html ?? "<p></p>",
});
},
[workspaceSlug, projectId, issueOperations]
[workspaceSlug, projectId, issueId, issueOperations]
);

const { getWorkspaceBySlug } = useWorkspace();
Expand All @@ -84,17 +84,14 @@ export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((p
});
}, [initialValue, issueId, reset]);

const debouncedHandleDescriptionFormSubmit = debounce(async (data: Partial<TIssue>, _issueId: string) => {
await handleDescriptionFormSubmit(data, _issueId);
setIsSubmitting("submitted");
}, 1500);

// ADDING handleDescriptionFormSubmit TO DEPENDENCY ARRAY PRODUCES ADVERSE EFFECTS
// TODO: Verify the exhaustive-deps warning
// eslint-disable-next-line react-hooks/exhaustive-deps
const debouncedFormSave = useCallback(
(_issueId: string) =>
handleSubmit((data) => {
debouncedHandleDescriptionFormSubmit(data, _issueId);
})(),
[debouncedHandleDescriptionFormSubmit, handleSubmit]
debounce(async () => {
handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted"));
}, 1500),
[handleSubmit, issueId]
);

return (
Expand All @@ -116,7 +113,7 @@ export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((p
onChange={(_description: object, description_html: string) => {
setIsSubmitting("submitting");
onChange(description_html);
debouncedFormSave(issueId);
debouncedFormSave();
}}
placeholder={
placeholder ? placeholder : (isFocused, value) => getDescriptionPlaceholder(isFocused, value)
Expand Down
4 changes: 2 additions & 2 deletions web/core/store/inbox/inbox-issue.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ export class InboxIssueStore implements IInboxIssueStore {
updateIssue = async (issue: Partial<TIssue>) => {
const inboxIssue = clone(this.issue);
try {
if (!issue.id) return;
if (!this.issue.id) return;
Object.keys(issue).forEach((key) => {
const issueKey = key as keyof TIssue;
set(this.issue, issueKey, issue[issueKey]);
});
await this.inboxIssueService.updateIssue(this.workspaceSlug, this.projectId, issue.id, issue);
await this.inboxIssueService.updateIssue(this.workspaceSlug, this.projectId, this.issue.id, issue);
// fetching activity
this.fetchIssueActivity();
} catch {
Expand Down