Commit 1edfe7452d88b203db8a281861c9a4c05a70610e
better calculation of the last reply to a thread
Dominic Tarr committed on 8/14/2017, 4:27:01 AMParent: dd1d12954ae9c549f848026f96a4d9320f69e9e2
Files changed
app/html/thread-card.js | changed |
app/html/thread-card.js | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 | var h = require('mutant/h') |
2 | -const last = require('lodash/last') | |
2 | +var lodash = require('lodash') | |
3 | 3 | var nest = require('depnest') |
4 | 4 | |
5 | 5 | exports.gives = nest('app.html.threadCard', true) |
6 | 6 | |
@@ -77,8 +77,9 @@ | ||
77 | 77 | } |
78 | 78 | |
79 | 79 | function subject (msg) { |
80 | 80 | const { subject, text } = msg.value.content |
81 | + if(!(subject || text)) return | |
81 | 82 | return api.message.html.markdown(firstLine(subject|| text)) |
82 | 83 | } |
83 | 84 | |
84 | 85 | return {app: {html: {threadCard: function (thread, opts = {}) { |
@@ -93,24 +94,25 @@ | ||
93 | 94 | : null, |
94 | 95 | subject(thread) |
95 | 96 | ]) |
96 | 97 | |
97 | - const lastReply = thread.replies && last(thread.replies) | |
98 | - const replyEl = lastReply | |
99 | - ? h('div.reply', [ | |
100 | - h('div.replySymbol', strings.replySymbol), | |
101 | - subject(lastReply) | |
102 | - ]) | |
103 | - : null | |
98 | + const lastReply = thread.replies && | |
99 | + lodash.maxBy(thread.replies, function (e) { return e.timestamp }) | |
100 | + if(thread.replies) | |
101 | + console.log(thread.replies.map(function (r) { | |
102 | + return r.timestamp - thread.timestamp | |
103 | + })) | |
104 | + var replySample = lastReply ? subject(lastReply) : null | |
104 | 105 | |
105 | 106 | return h('div.thread', link(thread), [ |
106 | 107 | h('div.context', threadIcon(thread)), |
107 | 108 | h('div.content', [ |
108 | 109 | subjectEl, |
109 | - replyEl | |
110 | + replySample ? h('div.reply', [ | |
111 | + h('div.replySymbol', strings.replySymbol), | |
112 | + replySample | |
113 | + ]) : null | |
110 | 114 | ]) |
111 | 115 | ]) |
112 | 116 | }}}} |
113 | 117 | } |
114 | 118 | |
115 | - | |
116 | - |
Built with git-ssb-web