modules/feed/html/rollup.jsView |
---|
147 | 147 | abortable, |
148 | 148 | Scroller(container, content, renderItem, false, false) |
149 | 149 | ) |
150 | 150 | } |
| 151 | + |
| 152 | + function renderItem (item) { |
| 153 | + if (item.type === 'message') { |
| 154 | + var meta = null |
| 155 | + var previousId = item.messageId |
| 156 | + var replies = item.replies.slice(-4).map((msg) => { |
| 157 | + var result = api.message.html.render(msg, {inContext: true, inSummary: true, previousId}) |
| 158 | + previousId = msg.key |
| 159 | + return result |
| 160 | + }) |
| 161 | + var renderedMessage = item.message ? api.message.html.render(item.message, {inContext: true}) : null |
| 162 | + if (renderedMessage) { |
| 163 | + if (item.lastUpdateType === 'reply' && item.repliesFrom.size) { |
| 164 | + meta = h('div.meta', { |
| 165 | + title: names(item.repliesFrom) |
| 166 | + }, [ |
| 167 | + api.profile.html.manyPeople(item.repliesFrom), ' replied' |
| 168 | + ]) |
| 169 | + } else if (item.lastUpdateType === 'dig' && item.digs.size) { |
| 170 | + meta = h('div.meta', { |
| 171 | + title: names(item.digs) |
| 172 | + }, [ |
| 173 | + api.profile.html.manyPeople(item.digs), ' dug this message' |
| 174 | + ]) |
| 175 | + } |
| 176 | + |
| 177 | + return h('FeedEvent', [ |
| 178 | + meta, |
| 179 | + renderedMessage, |
| 180 | + when(replies.length, [ |
| 181 | + when(item.replies.length > replies.length || opts.partial, |
| 182 | + h('a.full', {href: item.messageId}, ['View full thread']) |
| 183 | + ), |
| 184 | + h('div.replies', replies) |
| 185 | + ]) |
| 186 | + ]) |
| 187 | + } else { |
| 188 | + if (item.lastUpdateType === 'reply' && item.repliesFrom.size) { |
| 189 | + meta = h('div.meta', { |
| 190 | + title: names(item.repliesFrom) |
| 191 | + }, [ |
| 192 | + api.profile.html.manyPeople(item.repliesFrom), ' replied to ', api.message.html.link(item.messageId) |
| 193 | + ]) |
| 194 | + } else if (item.lastUpdateType === 'dig' && item.digs.size) { |
| 195 | + meta = h('div.meta', { |
| 196 | + title: names(item.digs) |
| 197 | + }, [ |
| 198 | + api.profile.html.manyPeople(item.digs), ' dug ', api.message.html.link(item.messageId) |
| 199 | + ]) |
| 200 | + } |
| 201 | + |
| 202 | + if (meta || replies.length) { |
| 203 | + return h('FeedEvent', [ |
| 204 | + meta, h('div.replies', replies) |
| 205 | + ]) |
| 206 | + } |
| 207 | + } |
| 208 | + } else if (item.type === 'follow') { |
| 209 | + return h('FeedEvent -follow', [ |
| 210 | + h('div.meta', { |
| 211 | + title: names(item.contacts) |
| 212 | + }, [ |
| 213 | + api.profile.html.person(item.id), ' followed ', api.profile.html.manyPeople(item.contacts) |
| 214 | + ]) |
| 215 | + ]) |
| 216 | + } |
| 217 | + |
| 218 | + return h('div') |
| 219 | + } |
151 | 220 | } |
152 | 221 | |
153 | 222 | function ensureAuthor (item, cb) { |
154 | 223 | if (item.type === 'message' && !item.message) { |
162 | 231 | cb(null, item) |
163 | 232 | } |
164 | 233 | } |
165 | 234 | |
166 | | - function renderItem (item) { |
167 | | - if (item.type === 'message') { |
168 | | - var meta = null |
169 | | - var previousId = item.messageId |
170 | | - var replies = item.replies.slice(-4).map((msg) => { |
171 | | - var result = api.message.html.render(msg, {inContext: true, inSummary: true, previousId}) |
172 | | - previousId = msg.key |
173 | | - return result |
174 | | - }) |
175 | | - var renderedMessage = item.message ? api.message.html.render(item.message, {inContext: true}) : null |
176 | | - if (renderedMessage) { |
177 | | - if (item.lastUpdateType === 'reply' && item.repliesFrom.size) { |
178 | | - meta = h('div.meta', { |
179 | | - title: names(item.repliesFrom) |
180 | | - }, [ |
181 | | - api.profile.html.manyPeople(item.repliesFrom), ' replied' |
182 | | - ]) |
183 | | - } else if (item.lastUpdateType === 'dig' && item.digs.size) { |
184 | | - meta = h('div.meta', { |
185 | | - title: names(item.digs) |
186 | | - }, [ |
187 | | - api.profile.html.manyPeople(item.digs), ' dug this message' |
188 | | - ]) |
189 | | - } |
190 | | - |
191 | | - return h('FeedEvent', [ |
192 | | - meta, |
193 | | - renderedMessage, |
194 | | - when(replies.length, [ |
195 | | - when(item.replies.length > replies.length, |
196 | | - h('a.full', {href: item.messageId}, ['View full thread']) |
197 | | - ), |
198 | | - h('div.replies', replies) |
199 | | - ]) |
200 | | - ]) |
201 | | - } else { |
202 | | - if (item.lastUpdateType === 'reply' && item.repliesFrom.size) { |
203 | | - meta = h('div.meta', { |
204 | | - title: names(item.repliesFrom) |
205 | | - }, [ |
206 | | - api.profile.html.manyPeople(item.repliesFrom), ' replied to ', api.message.html.link(item.messageId) |
207 | | - ]) |
208 | | - } else if (item.lastUpdateType === 'dig' && item.digs.size) { |
209 | | - meta = h('div.meta', { |
210 | | - title: names(item.digs) |
211 | | - }, [ |
212 | | - api.profile.html.manyPeople(item.digs), ' dug ', api.message.html.link(item.messageId) |
213 | | - ]) |
214 | | - } |
215 | | - |
216 | | - if (meta || replies.length) { |
217 | | - return h('FeedEvent', [ |
218 | | - meta, h('div.replies', replies) |
219 | | - ]) |
220 | | - } |
221 | | - } |
222 | | - } else if (item.type === 'follow') { |
223 | | - return h('FeedEvent -follow', [ |
224 | | - h('div.meta', { |
225 | | - title: names(item.contacts) |
226 | | - }, [ |
227 | | - api.profile.html.person(item.id), ' followed ', api.profile.html.manyPeople(item.contacts) |
228 | | - ]) |
229 | | - ]) |
230 | | - } |
231 | | - |
232 | | - return h('div') |
233 | | - } |
234 | | - |
235 | 235 | function names (ids) { |
236 | 236 | var items = map(ids, api.about.obs.name) |
237 | 237 | return computed([items], (names) => names.map((n) => `- ${n}`).join('\n')) |
238 | 238 | } |