Commit f736acde0d02447833cfd0c3a021d2d560e5c9a6
teach channel threadCards on homepage not to multi-push to history
mix irving committed on 8/15/2017, 4:27:10 AMParent: 8f874fd336bd2bf7721b161985bb987d55bc8179
Files changed
app/html/thread-card.js | changed |
app/page/home.js | changed |
app/html/thread-card.js | ||
---|---|---|
@@ -82,12 +82,13 @@ | ||
82 | 82 | subject(thread) |
83 | 83 | ]) |
84 | 84 | |
85 | 85 | const lastReply = thread.replies && maxBy(thread.replies, r => r.timestamp) |
86 | + const replySample = lastReply ? subject(lastReply) : null | |
86 | 87 | |
87 | - var replySample = lastReply ? subject(lastReply) : null | |
88 | + const onClick = opts.onClick || function () { api.history.sync.push(thread) } | |
88 | 89 | |
89 | - return h('div.thread', {'ev-click': () => api.history.sync.push(thread)}, [ | |
90 | + return h('div.thread', {'ev-click': onClick }, [ | |
90 | 91 | h('div.context', threadIcon(thread)), |
91 | 92 | h('div.content', [ |
92 | 93 | subjectEl, |
93 | 94 | replySample ? h('div.reply', [ |
app/page/home.js | ||
---|---|---|
@@ -105,21 +105,18 @@ | ||
105 | 105 | // but they are here to be compatible with the old MCSS. |
106 | 106 | h('div.container', [ |
107 | 107 | //private section |
108 | 108 | h('section.updates -directMessage', [ |
109 | - h('div.threads', | |
109 | + h('div.threads', | |
110 | 110 | groupedThreads |
111 | 111 | .map(function (thread) { |
112 | - var el = api.app.html.threadCard(thread) | |
113 | 112 | |
114 | - if(thread.value.content.channel) { | |
115 | - el.onclick = function (ev) { | |
116 | - api.history.sync.push({channel: thread.value.content.channel}) | |
117 | - ev.preventDefault() | |
118 | - } | |
119 | - } | |
113 | + const channel = thread.value.content.channel | |
114 | + const onClick = channel | |
115 | + ? (ev) => api.history.sync.push({ channel }) | |
116 | + : null // threadCard will install default onClick | |
120 | 117 | |
121 | - return el | |
118 | + return api.app.html.threadCard(thread, { onClick }) | |
122 | 119 | }) |
123 | 120 | ) |
124 | 121 | ]), |
125 | 122 | ]) |
Built with git-ssb-web