git ssb

10+

Matt McKegg / patchwork



Commit 7cda75eab5c68ce985a6dd1154a45acc301b29ec

better explanations of why you are seeing posts in main feed

fixes #655
#498
Matt McKegg committed on 12/15/2017, 5:59:33 AM
Parent: ce97eb85be66e3d5b599715f87eeb4ec854763cb

Files changed

locales/en.jsonchanged
modules/feed/html/rollup.jschanged
modules/page/html/render/public.jschanged
package.jsonchanged
sbot/roots.jschanged
styles/dark/channel-link.mcssadded
styles/light/channel-link.mcssadded
locales/en.jsonView
@@ -189,6 +189,12 @@
189189 "Font Size": "Font Size",
190190 "Public Feed Options": "Public Feed Options",
191191 "Only include posts from subscribed channels": "Only include posts from subscribed channels",
192192 "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.jsView
@@ -26,16 +26,18 @@
2626 'message.sync.isBlocked': 'first',
2727 'message.sync.unbox': 'first',
2828 'message.sync.timestamp': 'first',
2929 'profile.html.person': 'first',
30 + 'channel.html.link': 'first',
3031 'message.html.link': 'first',
3132 'message.sync.root': 'first',
3233 'feed.pull.rollup': 'first',
3334 'feed.pull.withReplies': 'first',
3435 'feed.pull.unique': 'first',
3536 'sbot.async.get': 'first',
3637 'keys.sync.id': 'first',
3738 'intl.sync.i18n': 'first',
39 + 'intl.sync.i18n_n': 'first',
3840 'message.html.missing': 'first'
3941 })
4042
4143 exports.gives = nest({
@@ -43,8 +45,9 @@
4345 })
4446
4547 exports.create = function (api) {
4648 const i18n = api.intl.sync.i18n
49 + const i18nPlural = api.intl.sync.i18n_n
4750 return nest('feed.html.rollup', function (getStream, {
4851 prepend,
4952 rootFilter = returnTrue,
5053 bumpFilter = returnTrue,
@@ -99,9 +102,9 @@
99102 ),
100103 pull.filter((msg) => {
101104 // only render posts that have a root message
102105 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)
104107 }),
105108 pull.drain((msg) => {
106109 if (msg.value.content.type === 'vote') return
107110 if (api.app.sync.externalHandler(msg)) return
@@ -233,17 +236,34 @@
233236
234237 unreadIds.delete(item.key)
235238
236239 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) {
238251 var bumps = lastBumpType === 'vote'
239252 ? getLikeAuthors(groupedBumps[lastBumpType])
240253 : getAuthors(groupedBumps[lastBumpType])
241254
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 + }
246266 }
247267
248268 // if there are new messages, view full thread goes to the top of those, otherwise to very first reply
249269 var anchorReply = highlightedReplies.length >= 3 ? highlightedReplies[0] : replies[0]
@@ -265,8 +285,12 @@
265285
266286 return result
267287 }
268288
289 + function channelLink (channelName) {
290 + return
291 + }
292 +
269293 function getPriority (msg) {
270294 if (highlightItems.has(msg.key)) {
271295 return 2
272296 } else if (unreadIds.has(msg.key)) {
modules/page/html/render/public.jsView
@@ -92,9 +92,14 @@
9292 var type = msg.value.content.type
9393 if (type === 'vote') return false
9494
9595 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 + }
97102 }
98103 },
99104 rootFilter: function (msg) {
100105 // skip messages that are directly replaced by the previous message
@@ -142,12 +147,16 @@
142147 return true
143148 }
144149
145150 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 + }
150159 }
151160
152161 function checkTag (mentions) {
153162 if (Array.isArray(mentions)) {
package.jsonView
@@ -40,9 +40,9 @@
4040 "mutant": "^3.21.2",
4141 "mutant-pull-reduce": "^1.1.0",
4242 "obv": "0.0.1",
4343 "patch-settings": "~1.1.0",
44- "patchcore": "~1.22.2",
44 + "patchcore": "~1.23.0",
4545 "pull-abortable": "^4.1.0",
4646 "pull-defer": "^0.2.2",
4747 "pull-file": "~1.0.0",
4848 "pull-identify-filetype": "^1.1.0",
sbot/roots.jsView
@@ -53,9 +53,12 @@
5353 var isPrivate = root.value && typeof root.value.content === 'string'
5454
5555 if (filter && root && root.value && !isPrivate) {
5656 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 + }
5861 }
5962 })
6063 ))
6164 })
@@ -106,16 +109,18 @@
106109 var isPrivate = root.value && typeof root.value.content === 'string'
107110
108111 // skip this item if it has already been included
109112 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})
112116 included.add(root.key)
113117 return true
114118 } else if (!seen.has(root.key)) {
115119 seen.add(root.key)
116120 var filterResult = filter(ids, root)
117121 if (shouldShow(filterResult, {onlySubscribedChannels})) {
122 + root.filterResult = filterResult
118123 included.add(root.key)
119124 return true
120125 }
121126 }
@@ -124,9 +129,8 @@
124129
125130 // MAP ROOT ITEMS
126131 pull.map(item => {
127132 var root = item.root || item
128- root.filterResult = item.filterResult
129133 return root
130134 })
131135 ))
132136 })
@@ -190,8 +194,13 @@
190194 var matchesChannel = (type !== 'channel' && checkChannel(subscriptions, ids, msg.value.content.channel))
191195 var matchingTags = getMatchingTags(subscriptions, ids, msg.value.content.mentions)
192196 var isYours = ids.includes(msg.value.author)
193197 var mentionsYou = getMentionsYou(ids, msg.value.content.mentions)
198 +
199 + if (msg.value.author === '@u1Q+EEna+cJ+JGYppltW0hNZPAkJikVtOH5oMYZ3cEA=.ed25519') {
200 + debugger
201 + }
202 +
194203 var following = checkFollowing(friends, ids, msg.value.author)
195204 if (isYours || matchesChannel || matchingTags.length || following || mentionsYou) {
196205 return {
197206 matchingTags, matchesChannel, isYours, following, mentionsYou, hasChannel
styles/dark/channel-link.mcssView
@@ -1,0 +1,3 @@
1 +ChannelLink {
2 + border-bottom: 1px dotted;
3 +}
styles/light/channel-link.mcssView
@@ -1,0 +1,5 @@
1 +ChannelLink {
2 + border-bottom: 1px dotted;
3 + color: #333
4 + font-weight: bold
5 +}

Built with git-ssb-web