From d86291eb79a857dc978cf91022fa0de11489cdfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Fri, 29 Nov 2024 17:03:52 +0100 Subject: [PATCH] Update comment count in second column when adding comments --- src/views/repo/Issue.svelte | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/views/repo/Issue.svelte b/src/views/repo/Issue.svelte index 474097972..15979e29f 100644 --- a/src/views/repo/Issue.svelte +++ b/src/views/repo/Issue.svelte @@ -115,6 +115,12 @@ new: { id: issue.id, body, embeds }, opts: { announce: $announce }, }); + // Update second column issue comment count without reloading the whole + // issue list. + const issueIndex = issues.findIndex(i => i.id === issue.id); + if (issueIndex !== -1) { + issues[issueIndex].commentCount += 1; + } } catch (error) { console.error("Comment creation failed: ", error); } finally { @@ -129,6 +135,12 @@ new: { id: issue.id, body, embeds, replyTo }, opts: { announce: $announce }, }); + // Update second column issue comment count without reloading the whole + // issue list. + const issueIndex = issues.findIndex(i => i.id === issue.id); + if (issueIndex !== -1) { + issues[issueIndex].commentCount += 1; + } } catch (error) { console.error("Comment reply creation failed", error); } finally { @@ -174,7 +186,7 @@ opts: { announce: $announce }, }); issue.title = updatedTitle; - // Update second colum issue title without reloading the whole issue list. + // Update second column issue title without reloading the whole issue list. const issueIndex = issues.findIndex(i => i.id === issue.id); if (issueIndex !== -1) { issues[issueIndex].title = updatedTitle;