Commit faee06d1f732247ca8640e9962e972ce73bfcee6
don't show multiple follow/unfollow messages for the same person in a row
Matt McKegg committed on 10/14/2017, 2:36:49 AMParent: 8f4b44fd5c96edb542eb7ebe86e16d6807a5abc5
Files changed
modules/page/html/render/public.js | changed |
modules/page/html/render/public.js | ||
---|---|---|
@@ -66,8 +66,10 @@ | ||
66 | 66 | return api.sbot.pull.stream(sbot => sbot.patchwork.roots(extend(opts, { ids: [id] }))) |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | + var lastMessage = null | |
71 | + | |
70 | 72 | var filters = api.settings.obs.get('filters') |
71 | 73 | var feedView = api.feed.html.rollup(getStream, { |
72 | 74 | prepend, |
73 | 75 | updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.latest({ids: [id]})), |
@@ -83,10 +85,16 @@ | ||
83 | 85 | return isSubscribed || id === author || following().includes(author) || tagged |
84 | 86 | } |
85 | 87 | }, |
86 | 88 | rootFilter: function (msg) { |
87 | - if (!filters()) return true | |
88 | - return !(filters().following && getType(msg) === 'contact') | |
89 | + var filtered = filters() && !(filters().following && getType(msg) === 'contact') | |
90 | + // skip messages that are directly replaced by the previous message | |
91 | + // e.g. follow / unfollow in quick succession | |
92 | + var isOutdated = isReplacementMessage(msg, lastMessage) | |
93 | + if (!filtered && !isOutdated) { | |
94 | + lastMessage = msg | |
95 | + return true | |
96 | + } | |
89 | 97 | }, |
90 | 98 | waitFor: computed([ |
91 | 99 | following.sync, |
92 | 100 | subscribedChannels.sync |
@@ -232,4 +240,13 @@ | ||
232 | 240 | if (Array.isArray(a) && Array.isArray(b) && a.length === b.length && a !== b) { |
233 | 241 | return a.every((value, i) => value === b[i]) |
234 | 242 | } |
235 | 243 | } |
244 | + | |
245 | +function isReplacementMessage (msgA, msgB) { | |
246 | + if (msgA && msgB && msgA.value.content && msgB.value.content && msgA.value.content.type === msgB.value.content.type) { | |
247 | + var type = msgA.value.content.type | |
248 | + if (type === 'contact') { | |
249 | + return msgA.value.author === msgB.value.author && msgA.value.content.contact === msgB.value.content.contact | |
250 | + } | |
251 | + } | |
252 | +} |
Built with git-ssb-web