git ssb

10+

Matt McKegg / patchwork



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 AM
Parent: 8f4b44fd5c96edb542eb7ebe86e16d6807a5abc5

Files changed

modules/page/html/render/public.jschanged
modules/page/html/render/public.jsView
@@ -66,8 +66,10 @@
6666 return api.sbot.pull.stream(sbot => sbot.patchwork.roots(extend(opts, { ids: [id] })))
6767 }
6868 }
6969
70+ var lastMessage = null
71+
7072 var filters = api.settings.obs.get('filters')
7173 var feedView = api.feed.html.rollup(getStream, {
7274 prepend,
7375 updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.latest({ids: [id]})),
@@ -83,10 +85,16 @@
8385 return isSubscribed || id === author || following().includes(author) || tagged
8486 }
8587 },
8688 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+ }
8997 },
9098 waitFor: computed([
9199 following.sync,
92100 subscribedChannels.sync
@@ -232,4 +240,13 @@
232240 if (Array.isArray(a) && Array.isArray(b) && a.length === b.length && a !== b) {
233241 return a.every((value, i) => value === b[i])
234242 }
235243 }
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