Commit 88efa57edc6f7800ae827d2a28a7aab3065c1159
fix scroller filter bug, add scroller to context.level.-two
mix irving committed on 11/19/2017, 8:27:12 AMParent: bc3baa90f43110f56698bc1c3de13714835c9d08
Files changed
app/html/context.js | changed |
app/html/scroller.js | changed |
app/html/context.js | ||
---|---|---|
@@ -92,9 +92,9 @@ | ||
92 | 92 | return api.app.html.scroller({ |
93 | 93 | classList: [ 'level', '-one' ], |
94 | 94 | prepend, |
95 | 95 | stream: api.feed.pull.private, |
96 | - filter: pull( | |
96 | + filter: () => pull( | |
97 | 97 | pull.filter(msg => msg.value.content.type === 'post'), // TODO is this the best way to protect against votes? |
98 | 98 | pull.filter(msg => msg.value.author != myKey), |
99 | 99 | pull.filter(msg => msg.value.content.recps), |
100 | 100 | pull.through(updateRecentMsgLog), |
@@ -122,33 +122,34 @@ | ||
122 | 122 | if (!targetUser) return |
123 | 123 | |
124 | 124 | var threads = MutantArray() |
125 | 125 | |
126 | - pull( | |
127 | - next(api.feed.pull.private, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']), | |
128 | - pull.filter(msg => msg.value.content.recps), | |
129 | - pull.filter(msg => msg.value.content.recps | |
130 | - .map(recp => typeof recp === 'object' ? recp.link : recp) | |
131 | - .some(recp => recp === targetUser) | |
126 | + const prepend = Option({ | |
127 | + selected: page === 'threadNew', | |
128 | + location: {page: 'threadNew', feed: targetUser}, | |
129 | + label: h('Button', strings.threadNew.action.new), | |
130 | + }) | |
131 | + | |
132 | + return api.app.html.scroller({ | |
133 | + classList: [ 'level', '-two' ], | |
134 | + prepend, | |
135 | + stream: api.feed.pull.private, | |
136 | + filter: () => pull( | |
137 | + pull.filter(msg => msg.value.content.recps), | |
138 | + pull.filter(msg => msg.value.content.recps | |
139 | + .map(recp => typeof recp === 'object' ? recp.link : recp) | |
140 | + .some(recp => recp === targetUser) | |
141 | + ), | |
142 | + api.feed.pull.rollup() // TODO - not technically a filter ...? | |
132 | 143 | ), |
133 | - api.feed.pull.rollup(), | |
134 | - pull.drain(thread => threads.push(thread)) | |
135 | - ) | |
136 | - | |
137 | - return h('div.level.-two', [ | |
138 | - Option({ | |
139 | - selected: page === 'threadNew', | |
140 | - location: {page: 'threadNew', feed: targetUser}, | |
141 | - label: h('Button', strings.threadNew.action.new), | |
142 | - }), | |
143 | - map(threads, thread => { | |
144 | + render: (thread) => { | |
144 | 145 | return Option({ |
145 | 146 | label: api.message.html.subject(thread), |
146 | 147 | selected: thread.key === root, |
147 | 148 | location: Object.assign(thread, { feed: targetUser }), |
148 | 149 | }) |
149 | - }, { comparer: (a, b) => a === b }) | |
150 | - ]) | |
150 | + } | |
151 | + }) | |
151 | 152 | } |
152 | 153 | |
153 | 154 | function Option ({ notifications = 0, imageEl, label, location, selected }) { |
154 | 155 | const className = selected ? '-selected' : '' |
app/html/scroller.js | ||
---|---|---|
@@ -15,72 +15,26 @@ | ||
15 | 15 | |
16 | 16 | function createScroller (opts = {}) { |
17 | 17 | const { |
18 | 18 | stream, |
19 | - filter = pull.filter((msg) => true), | |
20 | - // renderer, | |
19 | + filter = () => pull.filter((msg) => true), | |
20 | + // render, | |
21 | 21 | // classList = [], |
22 | - // content = h('section.content'), | |
23 | 22 | // prepend = [], |
24 | 23 | // append = [] |
25 | 24 | } = opts |
26 | 25 | |
27 | - const streamToTop = undefined | |
28 | - // pull( | |
29 | - // next(stream, {old: false, limit: 100}, ['value', 'timestamp']), | |
30 | - // filter // is a pull-stream through | |
31 | - // ) | |
26 | + const streamToTop = pull( | |
27 | + next(stream, {old: false, limit: 100}, ['value', 'timestamp']), | |
28 | + filter() // is a pull-stream through | |
29 | + ) | |
32 | 30 | |
33 | 31 | const streamToBottom = pull( |
34 | 32 | next(stream, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']), |
35 | - filter | |
33 | + filter() | |
36 | 34 | ) |
37 | 35 | |
38 | 36 | return Scroller(Object.assign({}, opts, { streamToTop, streamToBottom })) |
39 | - | |
40 | - // const scroller = h('Scroller', { classList, style: { overflow: 'auto' } }, [ | |
41 | - // h('div.wrapper', [ | |
42 | - // h('header', prepend), | |
43 | - // content, | |
44 | - // h('footer', append) | |
45 | - // ]) | |
46 | - // ]) | |
47 | - // // scroller.scroll = keyscroll(content) // used for e.g. reset | |
48 | - | |
49 | - // draw() | |
50 | - | |
51 | - // return { | |
52 | - // scroller, | |
53 | - // content, | |
54 | - // // reset, | |
55 | - // } | |
56 | - | |
57 | - // function draw () { | |
58 | - // reset() | |
59 | - | |
60 | - // if (streamTop) { | |
61 | - // pull( | |
62 | - // next(streamTop, {old: false, limit: 100}, ['value', 'timestamp']), | |
63 | - // filter, | |
64 | - // // filterDownThrough(), | |
65 | - // pullScroll(scroller, content, renderer, true, false) | |
66 | - // ) | |
67 | - // } | |
68 | - | |
69 | - // if (streamBottom) { | |
70 | - // pull( | |
71 | - // next(streamBottom, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']), | |
72 | - // filter, | |
73 | - // // filterUpThrough(), | |
74 | - // pullScroll(scroller, content, renderer, false, false) | |
75 | - // ) | |
76 | - // } | |
77 | - // } | |
78 | - | |
79 | - // function reset () { | |
80 | - // } | |
81 | - // } | |
82 | - | |
83 | 37 | } |
84 | 38 | } |
85 | 39 | |
86 | 40 | function keyscroll (content) { |
Built with git-ssb-web