app/html/context.jsView |
---|
32 | 32 | |
33 | 33 | pull( |
34 | 34 | next(api.feed.pull.private, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']), |
35 | 35 | pull.filter(msg => msg.value.content.recps), |
| 36 | + pull.filter(msg => msg.value.content.type === 'post'), |
36 | 37 | pull.drain(msg => { |
37 | 38 | msg.value.content.recps |
38 | 39 | .map(recp => typeof recp === 'object' ? recp.link : recp) |
39 | 40 | .filter(recp => recp != myKey) |
53 | 54 | function LevelOneContext () { |
54 | 55 | |
55 | 56 | return h('div.level.-one', [ |
56 | 57 | |
57 | | - computed(nearby, n => !isEmpty(n) ? h('header', strings.peopleNearby) : null), |
| 58 | + computed(nearby, n => !isEmpty(n) ? h('header', strings.peopleNearby) : null), |
58 | 59 | map(nearby, feedId => Option({ |
59 | 60 | notifications: Math.random() > 0.7 ? Math.floor(Math.random()*9+1) : 0, |
60 | 61 | imageEl: api.about.html.image(feedId), |
61 | 62 | label: api.about.obs.name(feedId), |
| 63 | + selected: location.feed === feedId, |
62 | 64 | location: computed(recentPeersContacted, recent => { |
63 | 65 | const lastMsg = recent[feedId] |
64 | 66 | return lastMsg |
65 | 67 | ? Object.assign(lastMsg, { feed: feedId }) |
66 | 68 | : { page: 'threadNew', feed: feedId } |
67 | 69 | }), |
68 | | - selected: location.feed === feedId |
69 | 70 | })), |
70 | 71 | computed(nearby, n => !isEmpty(n) ? h('hr') : null), |
71 | 72 | |
72 | 73 | |
73 | 74 | Option({ |
74 | 75 | notifications: Math.floor(Math.random()*5+1), |
75 | 76 | imageEl: h('i.fa.fa-binoculars'), |
76 | 77 | label: strings.blogIndex.title, |
| 78 | + selected: ['blogIndex', 'home'].includes(location.page), |
77 | 79 | location: { page: 'blogIndex' }, |
78 | | - selected: ['blogIndex', 'home'].includes(location.page) |
79 | 80 | }), |
80 | 81 | |
81 | 82 | |
82 | 83 | map(dictToCollection(recentPeersContacted), ({ key, value }) => { |
87 | 88 | return Option({ |
88 | 89 | notifications: Math.random() > 0.7 ? Math.floor(Math.random()*9+1) : 0, |
89 | 90 | imageEl: api.about.html.image(feedId), |
90 | 91 | label: api.about.obs.name(feedId), |
91 | | - location: Object.assign(lastMsg, { feed: feedId }), |
92 | | - selected: location.feed === feedId |
| 92 | + selected: location.feed === feedId, |
| 93 | + location: Object.assign(lastMsg, { feed: feedId }) |
93 | 94 | }) |
94 | 95 | }) |
95 | 96 | ]) |
96 | 97 | } |
120 | 121 | label: h('Button', strings.threadNew.action.new), |
121 | 122 | }), |
122 | 123 | map(threads, thread => { |
123 | 124 | return Option({ |
| 125 | + label: api.message.html.subject(thread), |
124 | 126 | selected: thread.key === root, |
125 | 127 | location: Object.assign(thread, { feed: targetUser }), |
126 | | - label: api.message.html.subject(thread) |
127 | 128 | }) |
128 | 129 | }) |
129 | 130 | ]) |
130 | 131 | } |
131 | 132 | |
132 | 133 | function Option ({ notifications = 0, imageEl, label, location, selected }) { |
133 | 134 | const className = selected ? '-selected' : '' |
134 | | - const goToLocation = () => api.history.sync.push(resolve(location)) |
| 135 | + const goToLocation = () => { |
| 136 | + api.history.sync.push(resolve(location)) |
| 137 | + } |
135 | 138 | |
136 | 139 | if (!imageEl) { |
137 | 140 | return h('Option', { className, 'ev-click': goToLocation }, [ |
138 | 141 | h('div.label', label) |