git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 753b6207164a2a3e5e07f5ea57b29a22559f9e4d

Add filter for following messages in feed

Michael LeGore committed on 9/18/2017, 8:13:11 PM
Parent: 60111a9e3385d65be0d17aa0d15fd20e5fb311ce

Files changed

modules/feed/html/rollup.jschanged
modules/page/html/render/settings.jschanged
modules/feed/html/rollup.jsView
@@ -26,9 +26,10 @@
2626 'message.html.link': 'first',
2727 'message.sync.root': 'first',
2828 'feed.pull.rollup': 'first',
2929 'sbot.async.get': 'first',
30- 'keys.sync.id': 'first'
30+ 'keys.sync.id': 'first',
31+ 'settings.obs.get': 'first',
3132 })
3233
3334 exports.gives = nest({
3435 'feed.html.rollup': true
@@ -77,8 +78,15 @@
7778 when(loading, h('Loading -large'))
7879 ])
7980 ])
8081
82+ const filters = api.settings.obs.get('filters')
83+ rootFilter = getFilter(filters())
84+ filters((filterSettings) => {
85+ rootFilter = getFilter(filterSettings)
86+ refresh()
87+ })
88+
8189 onceTrue(waitFor, () => {
8290 // display pending updates
8391 pull(
8492 updateStream || pull(
@@ -315,7 +323,13 @@
315323 function returnTrue () {
316324 return true
317325 }
318326
327+function getFilter (filterSettings) {
328+ return function(msg) {
329+ return !(filterSettings.following && getType(msg) === 'contact')
330+ }
331+}
332+
319333 function byAssertedTime (a, b) {
320334 return a.value.timestamp - b.value.timestamp
321335 }
modules/page/html/render/settings.jsView
@@ -14,8 +14,9 @@
1414 return nest('page.html.render', function channel (path) {
1515 if (path !== '/settings') return
1616
1717 const currentTheme = api.settings.obs.get('patchwork.theme')
18+ const filterFollowing = api.settings.obs.get('filters.following')
1819
1920 var prepend = [
2021 h('PageHeading', [
2122 h('h1', [
@@ -43,8 +44,25 @@
4344 style
4445 }, name)
4546 })
4647 })
48+ ]),
49+ h('section', [
50+ h('h2', 'Filters'),
51+ computed(filterFollowing, filter => {
52+ const style = filter
53+ ? { 'margin-right': '1rem', 'border-color': 'teal' }
54+ : { 'margin-right': '1rem' }
55+
56+ return [
57+ h('button', {
58+ 'ev-click': () => api.settings.sync.set({
59+ filters: {following: !filter}
60+ }),
61+ style
62+ }, filter ? 'Hide following messages' : 'Show following messages')
63+ ]
64+ })
4765 ])
4866 ])
4967 ])
5068 ])

Built with git-ssb-web