mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 02:52:33 -05:00
The activity feed rendered "edited comment undefined" / "deleted comment undefined" for comment edits and deletions. The template passed the comment's ID into the "%s" of activity-editComment / activity-deleteComment: on older activities the id was absent (literally "undefined"), and a deleted comment's CardComment document is already removed so it cannot be looked up live either. The edit and delete activities now store the comment text (commentText), and a new Activities.commentDisplayText() helper picks the stored text, else the live comment text (edit case), else an empty string — so the feed never renders the word "undefined". The template shows the (sanitized) comment text. The text-selection logic is a Meteor-free helper models/lib/commentActivity.js, unit tested (positive + negative) in tests/commentActivity.test.cjs. Thanks to janchuelo and xet7.
23 lines
1.1 KiB
JavaScript
23 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
// #3606 "activity feed shows 'edited comment undefined' / 'deleted comment
|
|
// undefined'". The activity template fed the comment's ID into the "%s" of the
|
|
// activity-editComment / activity-deleteComment strings. On older activities
|
|
// commentId was absent (→ literally "undefined"), and even when present it is an
|
|
// opaque id, not the comment text; for a DELETED comment the CardComment doc is
|
|
// already gone, so it cannot be looked up live either.
|
|
//
|
|
// The edit/delete activities now store the comment text (commentText), and this
|
|
// helper picks the best text to display — the stored text, else the live
|
|
// comment's text (edit case, comment still exists), else an empty string so the
|
|
// feed never renders the word "undefined". Meteor-free and unit tested.
|
|
function commentActivityDisplayText(activity) {
|
|
if (!activity) return '';
|
|
if (typeof activity.commentText === 'string') return activity.commentText;
|
|
const live = activity.comment;
|
|
if (live && typeof live.text === 'string') return live.text;
|
|
return '';
|
|
}
|
|
|
|
module.exports = { commentActivityDisplayText };
|