git ssb

10+

Matt McKegg / patchwork



Commit ff719d8d11108e133fbe0b77d5e7229f2412dd3e

channel: show tags as mentions

Matt McKegg committed on 6/21/2017, 1:17:11 AM
Parent: c716b471bbe343c03cd3c71042af8c3e0c44f09d

Files changed

modules/feed/html/rollup.jschanged
modules/page/html/render/channel.jschanged
modules/feed/html/rollup.jsView
@@ -10,11 +10,15 @@
1010 var bumpMessages = {
1111 'vote': 'liked this message',
1212 'post': 'replied to this message',
1313 'about': 'added changes',
14- 'mention': 'mentioned you'
14 + 'mention': 'mentioned you',
15 + 'channel-mention': 'mentioned this channel'
1516 }
1617
18 +// bump even for first message
19 +var rootBumpTypes = ['mention', 'channel-mention']
20 +
1721 exports.needs = nest({
1822 'about.obs.name': 'first',
1923 'app.sync.externalHandler': 'first',
2024 'message.html.render': 'first',
@@ -131,8 +135,14 @@
131135
132136 var groupedBumps = {}
133137 var lastBumpType = null
134138
139 + var rootBumpType = bumpFilter(item)
140 + if (rootBumpTypes.includes(rootBumpType)) {
141 + lastBumpType = rootBumpType
142 + groupedBumps[lastBumpType] = [item]
143 + }
144 +
135145 item.replies.forEach(msg => {
136146 var value = bumpFilter(msg)
137147 if (value) {
138148 var type = typeof value === 'string' ? value : getType(msg)
modules/page/html/render/channel.jsView
@@ -42,9 +42,24 @@
4242 placeholder: 'Write a message in this channel\n\n\n\nPeople who follow you or subscribe to this channel will also see this message in their main feed.\n\nTo create a new channel, type the channel name (preceded by a #) into the search box above. e.g #cat-pics'
4343 })
4444 ]
4545
46- return api.feed.html.rollup(api.feed.pull.channel(channel), { prepend, windowSize: 100 })
46 + return api.feed.html.rollup(api.feed.pull.channel(channel), {
47 + prepend,
48 + displayFilter: mentionFilter,
49 + bumpFilter: mentionFilter
50 + })
51 +
52 + function mentionFilter (msg) {
53 + if (msg.value.content.channel === channel) return true
54 + if (Array.isArray(msg.value.content.mentions)) {
55 + if (msg.value.content.mentions.some(mention => {
56 + return mention && mention.link === `#${channel}`
57 + })) {
58 + return 'channel-mention'
59 + }
60 + }
61 + }
4762 })
4863
4964 function subscribe (id) {
5065 // confirm

Built with git-ssb-web