Commit 17795d6b64c14a6b4619d142e0f05e3e8e3b2562
Merge remote-tracking branch 'origin/home_page_tweaks'
Dominic Tarr committed on 8/17/2017, 5:21:23 AMParent: e2d5bfd85bf6a1e43f4cf5d1f8b8980d5830ecba
Parent: c1e3521f9e2d90a0532d013640e269df8377760d
Files changed
app/html/thread-card.js | changed |
app/html/thread-card.js | ||
---|---|---|
@@ -20,19 +20,20 @@ | ||
20 | 20 | //get the first non-empty line |
21 | 21 | var line = text.trim().split('\n').shift().trim() |
22 | 22 | |
23 | 23 | //always break on a space, so that links are preserved. |
24 | - var i = line.indexOf(' ', 80) | |
24 | + const leadingMentionsLength = countLeadingMentions(line) | |
25 | + const i = line.indexOf(' ', leadingMentionsLength + 80) | |
25 | 26 | var sample = line.substring(0, ~i ? i : line.length) |
26 | 27 | |
27 | 28 | const ellipsis = (sample.length < line.length) ? '...' : '' |
28 | 29 | return sample + ellipsis |
29 | 30 | } |
30 | 31 | |
31 | -// function trimLeadingMentions (str) { | |
32 | -// return str.replace(/^(\s*\[@[^\)]+\)\s*)*/, '') | |
33 | -// // deletes any number of pattern " [@...) " from start of line | |
34 | -// } | |
32 | +function countLeadingMentions (str) { | |
33 | + return str.match(/^(\s*\[@[^\)]+\)\s*)*/)[0].length | |
34 | + // matches any number of pattern " [@...) " from start of line | |
35 | +} | |
35 | 36 | |
36 | 37 | exports.create = function (api) { |
37 | 38 | |
38 | 39 | //render the icon for a thread. |
@@ -85,9 +86,9 @@ | ||
85 | 86 | const lastReply = thread.replies && maxBy(thread.replies, r => r.timestamp) |
86 | 87 | const replySample = lastReply ? subject(lastReply) : null |
87 | 88 | |
88 | 89 | const onClick = opts.onClick || function () { api.history.sync.push(thread) } |
89 | - const id = `${thread.key}-${JSON.stringify(opts)}` | |
90 | + const id = `${thread.key.replace(/[^a-z0-9]/gi, '')}` //-${JSON.stringify(opts)}` | |
90 | 91 | // id is only here to help morphdom morph accurately |
91 | 92 | |
92 | 93 | return h('ThreadCard', { 'ev-click': onClick, id }, [ |
93 | 94 | h('div.context', threadIcon(thread)), |
Built with git-ssb-web