git ssb

10+

Matt McKegg / patchwork



Commit b1c890d592e7fb5f231385508a3bc61f145d4a5b

Merge branch 'filterSubscriptions' of https://github.com/mnzaki/patchwork

Matt McKegg committed on 1/29/2018, 10:22:01 PM
Parent: a67e6591ac50d45405a5cc7a30cba805fe7fa4d6
Parent: 13b1df716aa0e61f57f567bce7d3a64e14243907

Files changed

locales/en.jsonchanged
modules/page/html/render/channel.jschanged
modules/page/html/render/public.jschanged
modules/page/html/render/settings.jschanged
locales/en.jsonView
@@ -196,6 +196,8 @@
196196 "one": "%s person from your network replied to this message on ",
197197 "other": "%s people from your network replied to this message on "
198198 },
199199 "(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.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() && 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+
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
modules/page/html/render/public.jsView
@@ -140,10 +140,15 @@
140140
141141 return result
142142
143143 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
146151 }
147152 return true
148153 }
149154
modules/page/html/render/settings.jsView
@@ -26,9 +26,11 @@
2626 const theme = api.settings.obs.get('patchwork.theme', 'light')
2727 const lang = api.settings.obs.get('patchwork.lang', '')
2828 const fontSize = api.settings.obs.get('patchwork.fontSize', '')
2929 const filterFollowing = api.settings.obs.get('filters.following')
30+ const filterSubscriptions = api.settings.obs.get('filters.subscriptions')
3031 const onlySubscribed = api.settings.obs.get('filters.onlySubscribed')
32+ const filterChannelViewSubscriptions = api.settings.obs.get('filters.channelView.subscriptions')
3133
3234 var prepend = [
3335 h('PageHeading', [
3436 h('h1', [
@@ -88,15 +90,31 @@
8890 })
8991 ]),
9092
9193 h('div', [
94+ checkbox(filterSubscriptions, {
95+ label: i18n('Hide channel (un)subcribe messages')
96+ })
97+ ]),
98+
99+ h('div', [
92100 checkbox(onlySubscribed, {
93101 label: i18n('Only include posts from subscribed channels')
94102 })
95103 ])
96104 ]),
97105
98106 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', [
99117 h('h2', i18n('Information')),
100118
101119 h('p', `${packageInfo.productName} ${packageInfo.version}`)
102120 ])

Built with git-ssb-web