Commit b1c890d592e7fb5f231385508a3bc61f145d4a5b
Merge branch 'filterSubscriptions' of https://github.com/mnzaki/patchwork
Matt McKegg committed on 1/29/2018, 10:22:01 PMParent: a67e6591ac50d45405a5cc7a30cba805fe7fa4d6
Parent: 13b1df716aa0e61f57f567bce7d3a64e14243907
Files changed
locales/en.json | changed |
modules/page/html/render/channel.js | changed |
modules/page/html/render/public.js | changed |
modules/page/html/render/settings.js | changed |
locales/en.json | ||
---|---|---|
@@ -196,6 +196,8 @@ | ||
196 | 196 | "one": "%s person from your network replied to this message on ", |
197 | 197 | "other": "%s people from your network replied to this message on " |
198 | 198 | }, |
199 | 199 | "(you)": "(you)", |
200 | - "Information": "Information" | |
201 | -} | |
200 | + "Information": "Information", | |
201 | + "Hide channel (un)subcribe messages": "Hide channel (un)subcribe messages", | |
202 | + "Channel Feed Options": "Channel Feed Options" | |
203 | +} |
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() && filters().channelView; | |
66 | + if (filterObj) { | |
67 | + const msgType = msg && msg.value && msg.value.content && | |
68 | + msg.value.content.type | |
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 |
modules/page/html/render/public.js | ||
---|---|---|
@@ -140,10 +140,15 @@ | ||
140 | 140 | |
141 | 141 | return result |
142 | 142 | |
143 | 143 | function checkFeedFilter (root) { |
144 | - if (filters()) { | |
145 | - if (filters().following && getType(root) === 'contact') return false | |
144 | + const filterObj = filters() | |
145 | + if (filterObj) { | |
146 | + const rootType = getType(root) | |
147 | + if ( | |
148 | + filterObj.following && rootType === 'contact' || | |
149 | + filterObj.subscriptions && rootType === 'channel' | |
150 | + ) return false | |
146 | 151 | } |
147 | 152 | return true |
148 | 153 | } |
149 | 154 |
modules/page/html/render/settings.js | ||
---|---|---|
@@ -26,9 +26,11 @@ | ||
26 | 26 | const theme = api.settings.obs.get('patchwork.theme', 'light') |
27 | 27 | const lang = api.settings.obs.get('patchwork.lang', '') |
28 | 28 | const fontSize = api.settings.obs.get('patchwork.fontSize', '') |
29 | 29 | const filterFollowing = api.settings.obs.get('filters.following') |
30 | + const filterSubscriptions = api.settings.obs.get('filters.subscriptions') | |
30 | 31 | const onlySubscribed = api.settings.obs.get('filters.onlySubscribed') |
32 | + const filterChannelViewSubscriptions = api.settings.obs.get('filters.channelView.subscriptions') | |
31 | 33 | |
32 | 34 | var prepend = [ |
33 | 35 | h('PageHeading', [ |
34 | 36 | h('h1', [ |
@@ -88,15 +90,31 @@ | ||
88 | 90 | }) |
89 | 91 | ]), |
90 | 92 | |
91 | 93 | h('div', [ |
94 | + checkbox(filterSubscriptions, { | |
95 | + label: i18n('Hide channel (un)subcribe messages') | |
96 | + }) | |
97 | + ]), | |
98 | + | |
99 | + h('div', [ | |
92 | 100 | checkbox(onlySubscribed, { |
93 | 101 | label: i18n('Only include posts from subscribed channels') |
94 | 102 | }) |
95 | 103 | ]) |
96 | 104 | ]), |
97 | 105 | |
98 | 106 | h('section', [ |
107 | + h('h2', i18n('Channel Feed Options')), | |
108 | + | |
109 | + h('div', [ | |
110 | + checkbox(filterChannelViewSubscriptions, { | |
111 | + label: i18n('Hide channel (un)subcribe messages') | |
112 | + }) | |
113 | + ]) | |
114 | + ]), | |
115 | + | |
116 | + h('section', [ | |
99 | 117 | h('h2', i18n('Information')), |
100 | 118 | |
101 | 119 | h('p', `${packageInfo.productName} ${packageInfo.version}`) |
102 | 120 | ]) |
Built with git-ssb-web