fix: inbox issue initial data load (#3693)

* fix: inbox issue initial data load

* chore: removed unnecessary comments
This commit is contained in:
sriram veeraghanta 2024-02-19 00:17:31 +05:30 committed by GitHub
parent ce9ed6b25e
commit 261013b794
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 19 deletions

View File

@ -22,16 +22,13 @@ export type IssueDescriptionInputProps = {
issueOperations: TIssueOperations; issueOperations: TIssueOperations;
projectId: string; projectId: string;
issueId: string; issueId: string;
initialValue?: string;
}; };
export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((props) => { export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((props) => {
const { disabled, value, workspaceSlug, setIsSubmitting, issueId, issueOperations, projectId } = props; const { disabled, value, workspaceSlug, setIsSubmitting, issueId, issueOperations, projectId, initialValue } = props;
// states // states
const [descriptionHTML, setDescriptionHTML] = useState(value); const [descriptionHTML, setDescriptionHTML] = useState(value);
const [localIssueDescription, setLocalIssueDescription] = useState({
id: issueId,
description_html: typeof value === "string" && value != "" ? value : "<p></p>",
});
// store hooks // store hooks
const { mentionHighlights, mentionSuggestions } = useMention(); const { mentionHighlights, mentionSuggestions } = useMention();
const { getWorkspaceBySlug } = useWorkspace(); const { getWorkspaceBySlug } = useWorkspace();
@ -45,16 +42,7 @@ export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((p
}, [value]); }, [value]);
useEffect(() => { useEffect(() => {
if (issueId && value) if (debouncedValue && debouncedValue !== value) {
setLocalIssueDescription({
id: issueId,
description_html: typeof value === "string" && value != "" ? value : "<p></p>",
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [issueId, value]);
useEffect(() => {
if (debouncedValue || debouncedValue === "") {
setIsSubmitting("submitted"); setIsSubmitting("submitted");
issueOperations issueOperations
.update(workspaceSlug, projectId, issueId, { description_html: debouncedValue }, false) .update(workspaceSlug, projectId, issueId, { description_html: debouncedValue }, false)
@ -92,9 +80,7 @@ export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((p
deleteFile={fileService.getDeleteImageFunction(workspaceId)} deleteFile={fileService.getDeleteImageFunction(workspaceId)}
restoreFile={fileService.getRestoreImageFunction(workspaceId)} restoreFile={fileService.getRestoreImageFunction(workspaceId)}
value={descriptionHTML} value={descriptionHTML}
rerenderOnPropsChange={localIssueDescription} initialValue={initialValue}
// setShouldShowAlert={setShowAlert}
// setIsSubmitting={setIsSubmitting}
dragDropEnabled dragDropEnabled
customClassName="min-h-[150px] shadow-sm" customClassName="min-h-[150px] shadow-sm"
onChange={(description: Object, description_html: string) => { onChange={(description: Object, description_html: string) => {

View File

@ -79,6 +79,7 @@ export const InboxIssueMainContent: React.FC<Props> = observer((props) => {
issueOperations={issueOperations} issueOperations={issueOperations}
disabled={!is_editable} disabled={!is_editable}
value={issue.description_html} value={issue.description_html}
initialValue={issue.description_html}
/> />
{currentUser && ( {currentUser && (

View File

@ -31,7 +31,7 @@ export const IssueTitleInput: FC<IssueTitleInputProps> = observer((props) => {
}, [value]); }, [value]);
useEffect(() => { useEffect(() => {
if (debouncedValue) { if (debouncedValue && debouncedValue !== value) {
issueOperations.update(workspaceSlug, projectId, issueId, { name: debouncedValue }, false).finally(() => { issueOperations.update(workspaceSlug, projectId, issueId, { name: debouncedValue }, false).finally(() => {
setIsSubmitting("saved"); setIsSubmitting("saved");
}); });