git ssb

2+

mixmix / ticktack



Commit f2c1e3d81bf5bba14c878872f1c99529d7eb2be5

Merge pull request #12 from ticktackim/fix_home_page_onclicks

teach channel threadCards on homepage not to multi-push to history
mix irving authored on 8/15/2017, 4:28:06 AM
GitHub committed on 8/15/2017, 4:28:06 AM
Parent: 8f874fd336bd2bf7721b161985bb987d55bc8179
Parent: f736acde0d02447833cfd0c3a021d2d560e5c9a6

Files changed

app/html/thread-card.jschanged
app/page/home.jschanged
app/html/thread-card.jsView
@@ -82,12 +82,13 @@
8282 subject(thread)
8383 ])
8484
8585 const lastReply = thread.replies && maxBy(thread.replies, r => r.timestamp)
86+ const replySample = lastReply ? subject(lastReply) : null
8687
87- var replySample = lastReply ? subject(lastReply) : null
88+ const onClick = opts.onClick || function () { api.history.sync.push(thread) }
8889
89- return h('div.thread', {'ev-click': () => api.history.sync.push(thread)}, [
90+ return h('div.thread', {'ev-click': onClick }, [
9091 h('div.context', threadIcon(thread)),
9192 h('div.content', [
9293 subjectEl,
9394 replySample ? h('div.reply', [
app/page/home.jsView
@@ -105,21 +105,18 @@
105105 // but they are here to be compatible with the old MCSS.
106106 h('div.container', [
107107 //private section
108108 h('section.updates -directMessage', [
109- h('div.threads',
109+ h('div.threads',
110110 groupedThreads
111111 .map(function (thread) {
112- var el = api.app.html.threadCard(thread)
113112
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
120117
121- return el
118+ return api.app.html.threadCard(thread, { onClick })
122119 })
123120 )
124121 ]),
125122 ])

Built with git-ssb-web