Commit 753b6207164a2a3e5e07f5ea57b29a22559f9e4d
Add filter for following messages in feed
Michael LeGore committed on 9/18/2017, 8:13:11 PMParent: 60111a9e3385d65be0d17aa0d15fd20e5fb311ce
Files changed
modules/feed/html/rollup.js | changed |
modules/page/html/render/settings.js | changed |
modules/feed/html/rollup.js | ||
---|---|---|
@@ -26,9 +26,10 @@ | ||
26 | 26 | 'message.html.link': 'first', |
27 | 27 | 'message.sync.root': 'first', |
28 | 28 | 'feed.pull.rollup': 'first', |
29 | 29 | 'sbot.async.get': 'first', |
30 | - 'keys.sync.id': 'first' | |
30 | + 'keys.sync.id': 'first', | |
31 | + 'settings.obs.get': 'first', | |
31 | 32 | }) |
32 | 33 | |
33 | 34 | exports.gives = nest({ |
34 | 35 | 'feed.html.rollup': true |
@@ -77,8 +78,15 @@ | ||
77 | 78 | when(loading, h('Loading -large')) |
78 | 79 | ]) |
79 | 80 | ]) |
80 | 81 | |
82 | + const filters = api.settings.obs.get('filters') | |
83 | + rootFilter = getFilter(filters()) | |
84 | + filters((filterSettings) => { | |
85 | + rootFilter = getFilter(filterSettings) | |
86 | + refresh() | |
87 | + }) | |
88 | + | |
81 | 89 | onceTrue(waitFor, () => { |
82 | 90 | // display pending updates |
83 | 91 | pull( |
84 | 92 | updateStream || pull( |
@@ -315,7 +323,13 @@ | ||
315 | 323 | function returnTrue () { |
316 | 324 | return true |
317 | 325 | } |
318 | 326 | |
327 | +function getFilter (filterSettings) { | |
328 | + return function(msg) { | |
329 | + return !(filterSettings.following && getType(msg) === 'contact') | |
330 | + } | |
331 | +} | |
332 | + | |
319 | 333 | function byAssertedTime (a, b) { |
320 | 334 | return a.value.timestamp - b.value.timestamp |
321 | 335 | } |
modules/page/html/render/settings.js | ||
---|---|---|
@@ -14,8 +14,9 @@ | ||
14 | 14 | return nest('page.html.render', function channel (path) { |
15 | 15 | if (path !== '/settings') return |
16 | 16 | |
17 | 17 | const currentTheme = api.settings.obs.get('patchwork.theme') |
18 | + const filterFollowing = api.settings.obs.get('filters.following') | |
18 | 19 | |
19 | 20 | var prepend = [ |
20 | 21 | h('PageHeading', [ |
21 | 22 | h('h1', [ |
@@ -43,8 +44,25 @@ | ||
43 | 44 | style |
44 | 45 | }, name) |
45 | 46 | }) |
46 | 47 | }) |
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 | + }) | |
47 | 65 | ]) |
48 | 66 | ]) |
49 | 67 | ]) |
50 | 68 | ]) |
Built with git-ssb-web