Commit 4d59028f7e5dfb19b6a808394322180ab18e3b65
page/channel: filter subscription messages
Mina Nagy Zaki committed on 1/18/2018, 3:39:04 PMParent: 4e9194f9311080f62105ee0761ec396409f1fd2d
Files changed
modules/page/html/render/channel.js | changed |
modules/page/html/render/channel.js | ||
---|---|---|
@@ -9,9 +9,10 @@ | ||
9 | 9 | 'feed.pull.channel': 'first', |
10 | 10 | 'sbot.pull.log': 'first', |
11 | 11 | 'message.async.publish': 'first', |
12 | 12 | 'keys.sync.id': 'first', |
13 | - 'intl.sync.i18n': 'first' | |
13 | + 'intl.sync.i18n': 'first', | |
14 | + 'settings.obs.get': 'first' | |
14 | 15 | }) |
15 | 16 | |
16 | 17 | exports.gives = nest('page.html.render') |
17 | 18 | |
@@ -45,14 +46,34 @@ | ||
45 | 46 | placeholder: i18n('Write a message in this channel') |
46 | 47 | }) |
47 | 48 | ] |
48 | 49 | |
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 | + }) | |
54 | 58 | |
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 | + | |
55 | 76 | function mentionFilter (msg) { |
56 | 77 | // filter out likes |
57 | 78 | if (msg.value.content.type === 'vote') return false |
58 | 79 | if (api.channel.sync.normalize(msg.value.content.channel) === channel) return true |
Built with git-ssb-web