Merge pull request #4073 from adrapereira/ap_fixSidebarLinkCount
Fix: Link count on the topic sidebar
This commit is contained in:
commit
1ba65765e4
|
@ -21,27 +21,28 @@ export default createWidget('post-gutter', {
|
||||||
|
|
||||||
const seenTitles = {};
|
const seenTitles = {};
|
||||||
|
|
||||||
|
let titleCount = 0;
|
||||||
let i = 0;
|
links.forEach(function(l) {
|
||||||
while (i < links.length && result.length < toShow) {
|
|
||||||
const l = links[i++];
|
|
||||||
|
|
||||||
let title = l.title;
|
let title = l.title;
|
||||||
if (title && !seenTitles[title]) {
|
if (title && !seenTitles[title]) {
|
||||||
seenTitles[title] = true;
|
seenTitles[title] = true;
|
||||||
const linkBody = [new RawHtml({ html: `<span>${Discourse.Emoji.unescape(title)}</span>` })];
|
titleCount++;
|
||||||
if (l.clicks) {
|
if (result.length < toShow) {
|
||||||
linkBody.push(h('span.badge.badge-notification.clicks', l.clicks.toString()));
|
const linkBody = [new RawHtml({html: `<span>${Discourse.Emoji.unescape(title)}</span>`})];
|
||||||
}
|
if (l.clicks) {
|
||||||
|
linkBody.push(h('span.badge.badge-notification.clicks', l.clicks.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
const className = l.reflection ? 'inbound' : 'outbound';
|
const className = l.reflection ? 'inbound' : 'outbound';
|
||||||
const link = h('a.track-link', { className, attributes: { href: l.url } }, linkBody);
|
const link = h('a.track-link', {className, attributes: {href: l.url}}, linkBody);
|
||||||
result.push(h('li', link));
|
result.push(h('li', link));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (state.collapsed) {
|
if (state.collapsed) {
|
||||||
const remaining = links.length - MAX_GUTTER_LINKS;
|
const remaining = titleCount - MAX_GUTTER_LINKS;
|
||||||
|
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
result.push(h('li', h('a.toggle-more', I18n.t('post.more_links', {count: remaining}))));
|
result.push(h('li', h('a.toggle-more', I18n.t('post.more_links', {count: remaining}))));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue