git ssb

10+

Matt McKegg / patchwork



Commit 4d59028f7e5dfb19b6a808394322180ab18e3b65

page/channel: filter subscription messages

Mina Nagy Zaki committed on 1/18/2018, 3:39:04 PM
Parent: 4e9194f9311080f62105ee0761ec396409f1fd2d

Files changed

modules/page/html/render/channel.jschanged
modules/page/html/render/channel.jsView
@@ -9,9 +9,10 @@
99 'feed.pull.channel': 'first',
1010 'sbot.pull.log': 'first',
1111 'message.async.publish': 'first',
1212 'keys.sync.id': 'first',
13- 'intl.sync.i18n': 'first'
13+ 'intl.sync.i18n': 'first',
14+ 'settings.obs.get': 'first'
1415 })
1516
1617 exports.gives = nest('page.html.render')
1718
@@ -45,14 +46,34 @@
4546 placeholder: i18n('Write a message in this channel')
4647 })
4748 ]
4849
49- return api.feed.html.rollup(api.feed.pull.channel(channel), {
50- prepend,
51- displayFilter: mentionFilter,
52- bumpFilter: mentionFilter
53- })
50+ const filters = api.settings.obs.get('filters')
51+ const channelView = api.feed.html.rollup(
52+ api.feed.pull.channel(channel), {
53+ prepend,
54+ rootFilter: checkFeedFilter,
55+ displayFilter: mentionFilter,
56+ bumpFilter: mentionFilter
57+ })
5458
59+ // call reload whenever filters changes
60+ filters(channelView.reload)
61+
62+ return channelView
63+
64+ function checkFeedFilter (msg) {
65+ const filterObj = filters(),
66+ msgType = msg && msg.value && msg.value.content &&
67+ msg.value.content.type
68+ if (filterObj) {
69+ // filter out channel subscription messages
70+ if (filterObj.subscriptions && msgType === 'channel')
71+ return false
72+ }
73+ return true
74+ }
75+
5576 function mentionFilter (msg) {
5677 // filter out likes
5778 if (msg.value.content.type === 'vote') return false
5879 if (api.channel.sync.normalize(msg.value.content.channel) === channel) return true

Built with git-ssb-web