git ssb

2+

mixmix / ticktack



Commit 1edfe7452d88b203db8a281861c9a4c05a70610e

better calculation of the last reply to a thread

Dominic Tarr committed on 8/14/2017, 4:27:01 AM
Parent: dd1d12954ae9c549f848026f96a4d9320f69e9e2

Files changed

app/html/thread-card.jschanged
app/html/thread-card.jsView
@@ -1,6 +1,6 @@
11 var h = require('mutant/h')
2-const last = require('lodash/last')
2+var lodash = require('lodash')
33 var nest = require('depnest')
44
55 exports.gives = nest('app.html.threadCard', true)
66
@@ -77,8 +77,9 @@
7777 }
7878
7979 function subject (msg) {
8080 const { subject, text } = msg.value.content
81+ if(!(subject || text)) return
8182 return api.message.html.markdown(firstLine(subject|| text))
8283 }
8384
8485 return {app: {html: {threadCard: function (thread, opts = {}) {
@@ -93,24 +94,25 @@
9394 : null,
9495 subject(thread)
9596 ])
9697
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
104105
105106 return h('div.thread', link(thread), [
106107 h('div.context', threadIcon(thread)),
107108 h('div.content', [
108109 subjectEl,
109- replyEl
110+ replySample ? h('div.reply', [
111+ h('div.replySymbol', strings.replySymbol),
112+ replySample
113+ ]) : null
110114 ])
111115 ])
112116 }}}}
113117 }
114118
115-
116-

Built with git-ssb-web