From 9fb5e6c391558d236cfd471ce2236c672f5cf534 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Thu, 14 May 2026 16:17:54 +0200 Subject: [PATCH] automatically update xd score when new xd is added --- public/s/js/comments.js | 6 ++++++ src/inc/routes/comments.mjs | 1 + 2 files changed, 7 insertions(+) diff --git a/public/s/js/comments.js b/public/s/js/comments.js index dffd3ee..205f605 100644 --- a/public/s/js/comments.js +++ b/public/s/js/comments.js @@ -2612,6 +2612,12 @@ class CommentSystem { this.syncSubscribeButton(true); } + // Update xD score badge immediately from the POST response — + // faster and more reliable than waiting for the SSE NOTIFY. + if (typeof json.xd_score === 'number' && typeof window.updateXdBadgeFromScore === 'function') { + window.updateXdBadgeFromScore(this.itemId, json.xd_score); + } + this._silentSync(); this._finishSubmit(submitBtn, originalBtnHtml, parentId); } else { diff --git a/src/inc/routes/comments.mjs b/src/inc/routes/comments.mjs index 83a7f67..f368c21 100644 --- a/src/inc/routes/comments.mjs +++ b/src/inc/routes/comments.mjs @@ -445,6 +445,7 @@ export default (router, tpl) => { body: JSON.stringify({ success: true, comment: newComment[0], + xd_score: xdRow?.xd_score ?? null, is_new_subscription }) });