Commit 7cda75eab5c68ce985a6dd1154a45acc301b29ec
better explanations of why you are seeing posts in main feed
fixes #655 #498Matt McKegg committed on 12/15/2017, 5:59:33 AM
Parent: ce97eb85be66e3d5b599715f87eeb4ec854763cb
Files changed
locales/en.json | changed |
modules/feed/html/rollup.js | changed |
modules/page/html/render/public.js | changed |
package.json | changed |
sbot/roots.js | changed |
styles/dark/channel-link.mcss | added |
styles/light/channel-link.mcss | added |
locales/en.json | ||
---|---|---|
@@ -189,6 +189,12 @@ | ||
189 | 189 … | "Font Size": "Font Size", |
190 | 190 … | "Public Feed Options": "Public Feed Options", |
191 | 191 … | "Only include posts from subscribed channels": "Only include posts from subscribed channels", |
192 | 192 … | "Default": "Default", |
193 | - "Force Disconnect": "Force Disconnect" | |
194 | -} | |
193 … | + "Force Disconnect": "Force Disconnect", | |
194 … | + "mentioned in your network": "mentioned in your network", | |
195 … | + "%s people from your network replied to this message on ": { | |
196 … | + "one": "%s person from your network replied to this message on ", | |
197 … | + "other": "%s people from your network replied to this message on " | |
198 … | + }, | |
199 … | + "(you)": "(you)" | |
200 … | +} |
modules/feed/html/rollup.js | ||
---|---|---|
@@ -26,16 +26,18 @@ | ||
26 | 26 … | 'message.sync.isBlocked': 'first', |
27 | 27 … | 'message.sync.unbox': 'first', |
28 | 28 … | 'message.sync.timestamp': 'first', |
29 | 29 … | 'profile.html.person': 'first', |
30 … | + 'channel.html.link': 'first', | |
30 | 31 … | 'message.html.link': 'first', |
31 | 32 … | 'message.sync.root': 'first', |
32 | 33 … | 'feed.pull.rollup': 'first', |
33 | 34 … | 'feed.pull.withReplies': 'first', |
34 | 35 … | 'feed.pull.unique': 'first', |
35 | 36 … | 'sbot.async.get': 'first', |
36 | 37 … | 'keys.sync.id': 'first', |
37 | 38 … | 'intl.sync.i18n': 'first', |
39 … | + 'intl.sync.i18n_n': 'first', | |
38 | 40 … | 'message.html.missing': 'first' |
39 | 41 … | }) |
40 | 42 … | |
41 | 43 … | exports.gives = nest({ |
@@ -43,8 +45,9 @@ | ||
43 | 45 … | }) |
44 | 46 … | |
45 | 47 … | exports.create = function (api) { |
46 | 48 … | const i18n = api.intl.sync.i18n |
49 … | + const i18nPlural = api.intl.sync.i18n_n | |
47 | 50 … | return nest('feed.html.rollup', function (getStream, { |
48 | 51 … | prepend, |
49 | 52 … | rootFilter = returnTrue, |
50 | 53 … | bumpFilter = returnTrue, |
@@ -99,9 +102,9 @@ | ||
99 | 102 … | ), |
100 | 103 … | pull.filter((msg) => { |
101 | 104 … | // only render posts that have a root message |
102 | 105 … | var root = msg.root || msg |
103 | - return root && root.value && root.value.content && rootFilter(root) && bumpFilter(msg) && displayFilter(msg) | |
106 … | + return root && root.value && root.value.content && rootFilter(root) && bumpFilter(msg, root) && displayFilter(msg) | |
104 | 107 … | }), |
105 | 108 … | pull.drain((msg) => { |
106 | 109 … | if (msg.value.content.type === 'vote') return |
107 | 110 … | if (api.app.sync.externalHandler(msg)) return |
@@ -233,17 +236,34 @@ | ||
233 | 236 … | |
234 | 237 … | unreadIds.delete(item.key) |
235 | 238 … | |
236 | 239 … | if (!renderedMessage) return h('div') |
237 | - if (lastBumpType) { | |
240 … | + | |
241 … | + if (rootBumpType === 'matches-channel') { | |
242 … | + var channels = [] | |
243 … | + if (item.value.content.channel) channels.push(item.value.content.channel) | |
244 … | + if (item.filterResult && Array.isArray(item.filterResult.matchingTags)) { | |
245 … | + item.filterResult.matchingTags.forEach(x => channels.push(x)) | |
246 … | + } | |
247 … | + meta = h('div.meta', [ | |
248 … | + many(channels, api.channel.html.link, i18n), ' ', i18n('mentioned in your network') | |
249 … | + ]) | |
250 … | + } else if (lastBumpType) { | |
238 | 251 … | var bumps = lastBumpType === 'vote' |
239 | 252 … | ? getLikeAuthors(groupedBumps[lastBumpType]) |
240 | 253 … | : getAuthors(groupedBumps[lastBumpType]) |
241 | 254 … | |
242 | - var description = i18n(bumpMessages[lastBumpType] || 'added changes') | |
243 | - meta = h('div.meta', [ | |
244 | - many(bumps, api.profile.html.person, i18n), ' ', description | |
245 | - ]) | |
255 … | + if (lastBumpType === 'matches-channel' && item.value.content.channel) { | |
256 … | + var channel = api.channel.html.link(item.value.content.channel) | |
257 … | + meta = h('div.meta', [ | |
258 … | + i18nPlural('%s people from your network replied to this message on ', groupedBumps[lastBumpType].length), channel | |
259 … | + ]) | |
260 … | + } else { | |
261 … | + var description = i18n(bumpMessages[lastBumpType] || 'added changes') | |
262 … | + meta = h('div.meta', [ | |
263 … | + many(bumps, api.profile.html.person, i18n), ' ', description | |
264 … | + ]) | |
265 … | + } | |
246 | 266 … | } |
247 | 267 … | |
248 | 268 … | // if there are new messages, view full thread goes to the top of those, otherwise to very first reply |
249 | 269 … | var anchorReply = highlightedReplies.length >= 3 ? highlightedReplies[0] : replies[0] |
@@ -265,8 +285,12 @@ | ||
265 | 285 … | |
266 | 286 … | return result |
267 | 287 … | } |
268 | 288 … | |
289 … | + function channelLink (channelName) { | |
290 … | + return | |
291 … | + } | |
292 … | + | |
269 | 293 … | function getPriority (msg) { |
270 | 294 … | if (highlightItems.has(msg.key)) { |
271 | 295 … | return 2 |
272 | 296 … | } else if (unreadIds.has(msg.key)) { |
modules/page/html/render/public.js | ||
---|---|---|
@@ -92,9 +92,14 @@ | ||
92 | 92 … | var type = msg.value.content.type |
93 | 93 … | if (type === 'vote') return false |
94 | 94 … | |
95 | 95 … | var author = msg.value.author |
96 | - return matchesSubscribedChannel(msg) || id === author || following().includes(author) | |
96 … | + | |
97 … | + if (id === author || following().includes(author)) { | |
98 … | + return true | |
99 … | + } else if (matchesSubscribedChannel(msg)) { | |
100 … | + return 'matches-channel' | |
101 … | + } | |
97 | 102 … | } |
98 | 103 … | }, |
99 | 104 … | rootFilter: function (msg) { |
100 | 105 … | // skip messages that are directly replaced by the previous message |
@@ -142,12 +147,16 @@ | ||
142 | 147 … | return true |
143 | 148 … | } |
144 | 149 … | |
145 | 150 … | function matchesSubscribedChannel (msg) { |
146 | - var channel = api.channel.sync.normalize(msg.value.content.channel) | |
147 | - var tagged = checkTag(msg.value.content.mentions) | |
148 | - var isSubscribed = channel ? subscribedChannels().has(channel) : false | |
149 | - return isSubscribed || tagged | |
151 … | + if (msg.filterResult) { | |
152 … | + return msg.filterResult.matchesChannel || msg.filterResult.matchingTags.length | |
153 … | + } else { | |
154 … | + var channel = api.channel.sync.normalize(msg.value.content.channel) | |
155 … | + var tagged = checkTag(msg.value.content.mentions) | |
156 … | + var isSubscribed = channel ? subscribedChannels().has(channel) : false | |
157 … | + return isSubscribed || tagged | |
158 … | + } | |
150 | 159 … | } |
151 | 160 … | |
152 | 161 … | function checkTag (mentions) { |
153 | 162 … | if (Array.isArray(mentions)) { |
package.json | ||
---|---|---|
@@ -40,9 +40,9 @@ | ||
40 | 40 … | "mutant": "^3.21.2", |
41 | 41 … | "mutant-pull-reduce": "^1.1.0", |
42 | 42 … | "obv": "0.0.1", |
43 | 43 … | "patch-settings": "~1.1.0", |
44 | - "patchcore": "~1.22.2", | |
44 … | + "patchcore": "~1.23.0", | |
45 | 45 … | "pull-abortable": "^4.1.0", |
46 | 46 … | "pull-defer": "^0.2.2", |
47 | 47 … | "pull-file": "~1.0.0", |
48 | 48 … | "pull-identify-filetype": "^1.1.0", |
sbot/roots.js | ||
---|---|---|
@@ -53,9 +53,12 @@ | ||
53 | 53 … | var isPrivate = root.value && typeof root.value.content === 'string' |
54 | 54 … | |
55 | 55 … | if (filter && root && root.value && !isPrivate) { |
56 | 56 … | var filterResult = filter(ids, root) |
57 | - return checkReplyForcesDisplay(item) || shouldShow(filterResult, {onlySubscribedChannels}) | |
57 … | + if (checkReplyForcesDisplay(item) || shouldShow(filterResult, {onlySubscribedChannels})) { | |
58 … | + root.filterResult = filterResult | |
59 … | + return true | |
60 … | + } | |
58 | 61 … | } |
59 | 62 … | }) |
60 | 63 … | )) |
61 | 64 … | }) |
@@ -106,16 +109,18 @@ | ||
106 | 109 … | var isPrivate = root.value && typeof root.value.content === 'string' |
107 | 110 … | |
108 | 111 … | // skip this item if it has already been included |
109 | 112 … | if (!included.has(root.key) && filter && root && root.value && !isPrivate) { |
110 | - if (checkReplyForcesDisplay(item)) { | |
111 | - // include this item if it has matching tags or the author is you | |
113 … | + if (checkReplyForcesDisplay(item)) { // include this item if it has matching tags or the author is you | |
114 … | + // update filter result so that we can display the correct bump message | |
115 … | + root.filterResult = extend(item.filterResult, {forced: true}) | |
112 | 116 … | included.add(root.key) |
113 | 117 … | return true |
114 | 118 … | } else if (!seen.has(root.key)) { |
115 | 119 … | seen.add(root.key) |
116 | 120 … | var filterResult = filter(ids, root) |
117 | 121 … | if (shouldShow(filterResult, {onlySubscribedChannels})) { |
122 … | + root.filterResult = filterResult | |
118 | 123 … | included.add(root.key) |
119 | 124 … | return true |
120 | 125 … | } |
121 | 126 … | } |
@@ -124,9 +129,8 @@ | ||
124 | 129 … | |
125 | 130 … | // MAP ROOT ITEMS |
126 | 131 … | pull.map(item => { |
127 | 132 … | var root = item.root || item |
128 | - root.filterResult = item.filterResult | |
129 | 133 … | return root |
130 | 134 … | }) |
131 | 135 … | )) |
132 | 136 … | }) |
@@ -190,8 +194,13 @@ | ||
190 | 194 … | var matchesChannel = (type !== 'channel' && checkChannel(subscriptions, ids, msg.value.content.channel)) |
191 | 195 … | var matchingTags = getMatchingTags(subscriptions, ids, msg.value.content.mentions) |
192 | 196 … | var isYours = ids.includes(msg.value.author) |
193 | 197 … | var mentionsYou = getMentionsYou(ids, msg.value.content.mentions) |
198 … | + | |
199 … | + if (msg.value.author === '@u1Q+EEna+cJ+JGYppltW0hNZPAkJikVtOH5oMYZ3cEA=.ed25519') { | |
200 … | + debugger | |
201 … | + } | |
202 … | + | |
194 | 203 … | var following = checkFollowing(friends, ids, msg.value.author) |
195 | 204 … | if (isYours || matchesChannel || matchingTags.length || following || mentionsYou) { |
196 | 205 … | return { |
197 | 206 … | matchingTags, matchesChannel, isYours, following, mentionsYou, hasChannel |
Built with git-ssb-web