git ssb

2+

mixmix / ticktack



Commit dd1d12954ae9c549f848026f96a4d9320f69e9e2

simpler way to group posts to a channel

Dominic Tarr committed on 8/14/2017, 4:21:25 AM
Parent: 0752def91e23dd89d4a282c49488d79aaf7caa21

Files changed

app/page/home.jschanged
app/page/home.jsView
@@ -71,41 +71,73 @@
7171 morePlease = false
7272 })
7373 threadsObsDebounced.more = function () {
7474 morePlease = true
75- threadsObs.more()
75+ requestIdleCallback(threadsObs.more)
7676 }
7777
7878 var threadsHtmlObs = More(
7979 threadsObsDebounced,
8080 function render (threads) {
81+
82+ var groupedThreads =
83+ roots(threads.private)
84+ .concat(roots(threads.channels))
85+ .concat(roots(threads.groups))
86+ .sort(function (a, b) {
87+ return latestUpdate(b) - latestUpdate(a)
88+ })
89+
90+ function latestUpdate(thread) {
91+ var m = thread.timestamp
92+ if(!thread.replies) return m
93+
94+ for(var i = 0; i < thread.replies.length; i++)
95+ m = Math.max(thread.replies[i].timestamp, m)
96+ return m
97+ }
98+
99+ function roots (r) {
100+ return Object.keys(r || {}).map(function (k) {
101+ return threads.roots[r[k]]
102+ }).filter(function (e) {
103+ return e && e.value
104+ })
105+ }
106+
107+
81108 morphdom(container,
82109 // LEGACY: some of these containers could be removed
83110 // but they are here to be compatible with the old MCSS.
84111 h('div.container', [
85112 //private section
86113 h('section.updates -directMessage', [
87114 h('div.threads',
88- Object.keys(threads.roots)
89- .map(function (id) {
90- return threads.roots[id]
91- })
92- .filter(function (thread) {
93- return filter(location.filter, thread)
94- })
115+// Object.keys(threads.roots)
116+// .map(function (id) {
117+// return threads.roots[id]
118+// })
119+// .filter(function (thread) {
120+// return filter(location.filter, thread)
121+// })
122+ groupedThreads
95123 .map(function (thread) {
96124 var el = api.app.html
97125 .threadCard(thread, opts)
98- if(!location.filter && el)
99- el.onclick = function () {
100- api.history.sync.push({page: 'home', filter: filterForThread(thread)})
101- }
126+//DISABLE: rethinking pages
127+// if(!location.filter && el)
128+// el.onclick = function () {
129+// if(!filterForThread(thread))
130+// api.history.sync.push({key: thread.key})
131+// else
132+// api.history.sync.push({page: 'home', filter: filterForThread(thread)})
133+// }
102134 return el
103135 })
104136 )
105137 ]),
106138 ])
107- )
139+ )
108140 return container
109141 }
110142 )
111143
@@ -118,4 +150,13 @@
118150 })
119151 }
120152
121153
154+
155+
156+
157+
158+
159+
160+
161+
162+

Built with git-ssb-web