Commit 452d3838ab4f6ffb18b71fff39793437a4d88c4e
scroll to start of highlighted messages when viewing full thread
Matt McKegg committed on 11/20/2017, 3:32:21 AMParent: 217c274425bfc6f97a221190b58a329730ab0482
Files changed
modules/feed/html/rollup.js | changed |
modules/feed/html/rollup.js | ||
---|---|---|
@@ -192,8 +192,9 @@ | ||
192 | 192 | } |
193 | 193 | }) |
194 | 194 | |
195 | 195 | var replies = item.replies.filter(isReply).sort(byAssertedTime) |
196 | + var highlightedReplies = replies.filter(isHighlighted) | |
196 | 197 | var replyElements = replies.filter(displayFilter).slice(-3).map((msg) => { |
197 | 198 | var result = api.message.html.render(msg, { |
198 | 199 | previousId, |
199 | 200 | compact: compactFilter(msg, item), |
@@ -224,21 +225,28 @@ | ||
224 | 225 | many(bumps, api.profile.html.person, i18n), ' ', description |
225 | 226 | ]) |
226 | 227 | } |
227 | 228 | |
229 | + // if there are new messages, view full thread goes to the top of those, otherwise to very first reply | |
230 | + var anchorReply = highlightedReplies.length >= 3 ? highlightedReplies[0] : replies[0] | |
231 | + | |
228 | 232 | return h('FeedEvent -post', { |
229 | 233 | attributes: { |
230 | 234 | 'data-root-id': item.key |
231 | 235 | } |
232 | 236 | }, [ |
233 | 237 | meta, |
234 | 238 | renderedMessage, |
235 | 239 | when(replies.length > replyElements.length || partial, |
236 | - h('a.full', {href: item.key, anchor: replies[0] && replies[0].key}, [i18n('View full thread') + ' (', replies.length, ')']) | |
240 | + h('a.full', {href: item.key, anchor: anchorReply && anchorReply.key}, [i18n('View full thread') + ' (', replies.length, ')']) | |
237 | 241 | ), |
238 | 242 | h('div.replies', replyElements) |
239 | 243 | ]) |
240 | 244 | } |
245 | + | |
246 | + function isHighlighted (msg) { | |
247 | + return highlightItems.has(msg.key) | |
248 | + } | |
241 | 249 | }) |
242 | 250 | |
243 | 251 | function LookupRoot () { |
244 | 252 | return paramap((msg, cb) => { |
Built with git-ssb-web