Commit 48bebcda44d351b3e77a42a761d37c9ff72ec9f0
Merge branch 'filter'
mix irving committed on 8/17/2017, 3:55:30 AMParent: 8d96f1ca26597e7a20fe4f1aa1d5ff63ee880700
Parent: ec2e673495eb4d062dcc4ddda74abbd628303d69
Files changed
app/page/channel.js | changed |
app/page/home.js | changed |
app/page/channel.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | 2 | const { h, computed } = require('mutant') |
3 | 3 | const More = require('hypermore') |
4 | 4 | const morphdom = require('morphdom') |
5 | +const get = require('lodash/get') | |
5 | 6 | |
6 | 7 | exports.gives = nest('app.page.channel') |
7 | 8 | |
8 | 9 | exports.needs = nest({ |
@@ -22,39 +23,32 @@ | ||
22 | 23 | } |
23 | 24 | |
24 | 25 | exports.create = (api) => { |
25 | 26 | return nest('app.page.channel', function (location) { |
26 | - // location here can expected to be: { page: 'home' } | |
27 | + const { channel } = location | |
27 | 28 | var strings = api.translations.sync.strings() |
28 | 29 | |
29 | 30 | var container = h('div.container', []) |
30 | 31 | |
31 | - var channelObs = api.state.obs.channel(location.channel) | |
32 | + var channelObs = api.state.obs.channel(channel) | |
32 | 33 | |
33 | 34 | //disable "Show More" button when we are at the last thread. |
34 | 35 | var disableShowMore = computed([channelObs], threads => !!threads.ended) |
35 | 36 | |
36 | 37 | var threadsHtmlObs = More( |
37 | 38 | channelObs, |
38 | 39 | function render (threads) { |
39 | - | |
40 | 40 | morphdom(container, |
41 | 41 | // LEGACY: some of these containers could be removed |
42 | 42 | // but they are here to be compatible with the old MCSS. |
43 | 43 | h('div.container', [ |
44 | 44 | //private section |
45 | 45 | h('section.updates -directMessage', [ |
46 | - h('div.threads', | |
47 | - Object.keys(threads.roots) | |
48 | - .map(function (id) { | |
49 | - return threads.roots[id] | |
50 | - }) | |
51 | - .sort(function (a, b) { | |
52 | - return latestUpdate(b) - latestUpdate(a) | |
53 | - }) | |
54 | - .map(function (thread) { | |
55 | - return api.app.html.threadCard(thread) | |
56 | - }) | |
46 | + h('div.threads', Object.keys(threads.roots) | |
47 | + .map(id => threads.roots[id]) | |
48 | + .filter(thread => get(thread, 'value.content.channel') == channel) | |
49 | + .sort((a, b) => latestUpdate(b) - latestUpdate(a)) | |
50 | + .map(thread => api.app.html.threadCard(thread)) | |
57 | 51 | ) |
58 | 52 | ]) |
59 | 53 | ]) |
60 | 54 | ) |
@@ -72,5 +66,4 @@ | ||
72 | 66 | }) |
73 | 67 | } |
74 | 68 | |
75 | 69 | |
76 | - |
app/page/home.js | ||
---|---|---|
@@ -76,8 +76,11 @@ | ||
76 | 76 | var groupedThreads = |
77 | 77 | roots(threads.private) |
78 | 78 | .concat(roots(threads.channels)) |
79 | 79 | .concat(roots(threads.groups)) |
80 | + .filter(function (thread) { | |
81 | + return thread.value.content.recps || thread.value.content.channel | |
82 | + }) | |
80 | 83 | .sort(function (a, b) { |
81 | 84 | return latestUpdate(b) - latestUpdate(a) |
82 | 85 | }) |
83 | 86 |
Built with git-ssb-web