diff --git a/backend/internal/web/handlers_discussion.go b/backend/internal/web/handlers_discussion.go index 07ca9a9..062a3ec 100644 --- a/backend/internal/web/handlers_discussion.go +++ b/backend/internal/web/handlers_discussion.go @@ -29,7 +29,10 @@ func loadDiscussionTabData(w http.ResponseWriter, r *http.Request, q *sqlc.Queri http.Error(w, "internal server error", http.StatusInternalServerError) return templates.DiscussionTabData{}, false } - data := templates.DiscussionTabData{Messages: templates.DiscussionMessagesFromRows(rows, currentUserID)} + data := templates.DiscussionTabData{ + Messages: templates.DiscussionMessagesFromRows(rows, currentUserID), + CurrentUserID: currentUserID, + } return data, true } diff --git a/backend/static/discussion-sse.js b/backend/static/discussion-sse.js index 6c8059b..7834be2 100644 --- a/backend/static/discussion-sse.js +++ b/backend/static/discussion-sse.js @@ -42,6 +42,12 @@ if (!event || !event.messageId || !event.messageHtml || messageExists(event.messageId)) { return; } + // Skip messages authored by the current user — HTMX already appended them + // with IsOwn=true. Let SSE handle only messages from other users. + var currentUserId = container.dataset.currentUserId; + if (currentUserId && event.authorUserId === currentUserId) { + return; + } var list = ensureMessageList(container); if (!list) return; diff --git a/backend/templates/discussion.templ b/backend/templates/discussion.templ index de981c5..d830f19 100644 --- a/backend/templates/discussion.templ +++ b/backend/templates/discussion.templ @@ -8,7 +8,7 @@ import ( ) templ DiscussionTabFragment(tablo sqlc.Tablo, data DiscussionTabData, form DiscussionForm, errs DiscussionErrors, csrfToken string) { -