another pathetic try to fix the sidebar shit

This commit is contained in:
2026-07-16 22:51:16 +02:00
parent 353fc382de
commit 8d9fa3fafd
2 changed files with 18 additions and 3 deletions

View File

@@ -499,6 +499,19 @@
</div>`; </div>`;
} }
// Robust fallback for is_long if server didn't provide it, plus inline media checks
let isLong = c.is_long;
const rawText = c.content || c.body || '';
if (isLong === undefined) {
isLong = rawText.length > 120
|| rawText.split('\n').length > 2
|| (c.files && c.files.length > 0);
}
// Always force isLong if there are inline media tags that expand vertically
if (!isLong && /\[(video|audio|youtube|img)\]|!\[|https?:\/\//i.test(rawText)) {
isLong = true;
}
return ` return `
<div class="comment" id="sc${c.id}"> <div class="comment" id="sc${c.id}">
<div class="comment-body"> <div class="comment-body">
@@ -511,7 +524,7 @@
</div> </div>
<span class="comment-time timeago" tooltip="${fullDate}" style="font-size: 0.75em;"${tsAttr}>${timeStr}</span> <span class="comment-time timeago" tooltip="${fullDate}" style="font-size: 0.75em;"${tsAttr}>${timeStr}</span>
</div> </div>
<div class="comment-content${c.is_long ? ' has-overflow' : ''}"><div class="comment-content-inner">${displayContent}${attachmentsHtml}${pollHtml}</div><button class="read-more-btn"${c.is_long ? ' style="display:block"' : ''}>${window.f0ckI18n?.sidebar_read_more || 'read more'}</button></div> <div class="comment-content${isLong ? ' has-overflow' : ''}"><div class="comment-content-inner">${displayContent}${attachmentsHtml}${pollHtml}</div><button class="read-more-btn"${isLong ? ' style="display:block"' : ''}>${window.f0ckI18n?.sidebar_read_more || 'read more'}</button></div>
${itemPreview} ${itemPreview}
</div> </div>
</div>`; </div>`;

View File

@@ -614,7 +614,8 @@ export default (router, tpl) => {
// sidebar renders the correct clamped state immediately on first paint. // sidebar renders the correct clamped state immediately on first paint.
const activityIsLong = content.length > 120 const activityIsLong = content.length > 120
|| content.split('\n').length > 2 || content.split('\n').length > 2
|| activityFiles.length > 0; || activityFiles.length > 0
|| /\[(video|audio|youtube|img)\]|!\[|https?:\/\//i.test(content);
db.notify('activity', JSON.stringify({ db.notify('activity', JSON.stringify({
user_id: req.session.id, user_id: req.session.id,
item_id: item_id, item_id: item_id,
@@ -1103,7 +1104,8 @@ export default (router, tpl) => {
// attachments (images/video) will also push height above the limit. // attachments (images/video) will also push height above the limit.
const isLong = commentContent.length > 120 const isLong = commentContent.length > 120
|| commentContent.split('\n').length > 2 || commentContent.split('\n').length > 2
|| commentFiles.length > 0; || commentFiles.length > 0
|| /\[(video|audio|youtube|img)\]|!\[|https?:\/\//i.test(commentContent);
return { return {
...c, ...c,