Commit ff719d8d11108e133fbe0b77d5e7229f2412dd3e
channel: show tags as mentions
Matt McKegg committed on 6/21/2017, 1:17:11 AMParent: c716b471bbe343c03cd3c71042af8c3e0c44f09d
Files changed
modules/feed/html/rollup.js | changed |
modules/page/html/render/channel.js | changed |
modules/feed/html/rollup.js | ||
---|---|---|
@@ -10,11 +10,15 @@ | ||
10 | 10 | var bumpMessages = { |
11 | 11 | 'vote': 'liked this message', |
12 | 12 | 'post': 'replied to this message', |
13 | 13 | 'about': 'added changes', |
14 | - 'mention': 'mentioned you' | |
14 | + 'mention': 'mentioned you', | |
15 | + 'channel-mention': 'mentioned this channel' | |
15 | 16 | } |
16 | 17 | |
18 | +// bump even for first message | |
19 | +var rootBumpTypes = ['mention', 'channel-mention'] | |
20 | + | |
17 | 21 | exports.needs = nest({ |
18 | 22 | 'about.obs.name': 'first', |
19 | 23 | 'app.sync.externalHandler': 'first', |
20 | 24 | 'message.html.render': 'first', |
@@ -131,8 +135,14 @@ | ||
131 | 135 | |
132 | 136 | var groupedBumps = {} |
133 | 137 | var lastBumpType = null |
134 | 138 | |
139 | + var rootBumpType = bumpFilter(item) | |
140 | + if (rootBumpTypes.includes(rootBumpType)) { | |
141 | + lastBumpType = rootBumpType | |
142 | + groupedBumps[lastBumpType] = [item] | |
143 | + } | |
144 | + | |
135 | 145 | item.replies.forEach(msg => { |
136 | 146 | var value = bumpFilter(msg) |
137 | 147 | if (value) { |
138 | 148 | var type = typeof value === 'string' ? value : getType(msg) |
modules/page/html/render/channel.js | ||
---|---|---|
@@ -42,9 +42,24 @@ | ||
42 | 42 | 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' |
43 | 43 | }) |
44 | 44 | ] |
45 | 45 | |
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 | + } | |
47 | 62 | }) |
48 | 63 | |
49 | 64 | function subscribe (id) { |
50 | 65 | // confirm |
Built with git-ssb-web