git ssb

2+

mixmix / ticktack



Commit 5a9fd871c7f581b104a466ff3ce3d199b38541f5

threadCard: tweak subject for leading mentions, modify morphdom id

mix irving committed on 8/17/2017, 12:00:06 AM
Parent: f61a6365dcfa4962dd501e41f3afb98a390c9947

Files changed

app/html/thread-card.jschanged
app/html/thread-card.jsView
@@ -20,19 +20,20 @@
2020 //get the first non-empty line
2121 var line = text.trim().split('\n').shift().trim()
2222
2323 //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)
2526 var sample = line.substring(0, ~i ? i : line.length)
2627
2728 const ellipsis = (sample.length < line.length) ? '...' : ''
2829 return sample + ellipsis
2930 }
3031
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+}
3536
3637 exports.create = function (api) {
3738
3839 //render the icon for a thread.
@@ -85,9 +86,9 @@
8586 const lastReply = thread.replies && maxBy(thread.replies, r => r.timestamp)
8687 const replySample = lastReply ? subject(lastReply) : null
8788
8889 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)}`
9091 // id is only here to help morphdom morph accurately
9192
9293 return h('ThreadCard', { 'ev-click': onClick, id }, [
9394 h('div.context', threadIcon(thread)),

Built with git-ssb-web