git ssb

16+

Dominic / patchbay



Commit 3e60dda1e812310490b6488b0bf340185fafee3d

add filter to channels + search

mix irving committed on 4/24/2017, 12:07:39 PM
Parent: 6467ad6706ef51626af91215418ef301e9e62be7

Files changed

app/html/page/channel.jschanged
app/html/page/public.jschanged
app/html/page/search.jschanged
app/html/page/channel.jsView
@@ -4,10 +4,13 @@
44
55 exports.gives = nest('app.html.page')
66
77 exports.needs = nest({
8 + 'app.html': {
9 + filter: 'first',
10 + scroller: 'first'
11 + },
812 'feed.pull.channel': 'first',
9- 'app.html.scroller': 'first',
1013 message: {
1114 html: {
1215 compose: 'first',
1316 render: 'first'
@@ -21,24 +24,31 @@
2124
2225 function channelView (path) {
2326 if (path && !path.match(/#[^\s]+/)) return
2427
25- var channel = path.substr(1)
28 + const channel = path.substr(1)
29 + const composer = api.message.html.compose({ meta: { type: 'post', channel } })
30 + const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
31 + const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu] })
2632
27- var composer = api.message.html.compose({ meta: { type: 'post', channel } })
28- var { container, content } = api.app.html.scroller({ prepend: composer })
33 + function draw () {
34 + resetFeed({ container, content })
2935
30- var openChannelSource = api.feed.pull.channel(channel)
36 + const openChannelSource = api.feed.pull.channel(channel)
3137
32- pull(
33- openChannelSource({old: false}),
34- Scroller(container, content, api.message.html.render, true, false)
35- )
38 + pull(
39 + openChannelSource({old: false}),
40 + filterUpThrough(),
41 + Scroller(container, content, api.message.html.render, true, false)
42 + )
3643
37- pull(
38- openChannelSource({reverse: true}),
39- Scroller(container, content, api.message.html.render, false, false)
40- )
44 + pull(
45 + openChannelSource({reverse: true}),
46 + filterDownThrough(),
47 + Scroller(container, content, api.message.html.render, false, false)
48 + )
49 + }
50 + draw()
4151
4252 return container
4353 }
4454 }
app/html/page/public.jsView
@@ -67,8 +67,9 @@
6767 )
6868 }
6969 draw()
7070
71 +
7172 return container
7273 }
7374 }
7475
app/html/page/search.jsView
@@ -8,9 +8,12 @@
88
99 exports.gives = nest('app.html.page')
1010
1111 exports.needs = nest({
12- 'app.html.scroller': 'first',
12 + 'app.html': {
13 + filter: 'first',
14 + scroller: 'first'
15 + },
1316 'message.html.render': 'first',
1417 'sbot.pull': {
1518 log: 'first',
1619 search: 'first'
@@ -108,41 +111,52 @@
108111 when(hasNoFulltextMatches, h('div.matches', 'No matches'))
109112 ])
110113 )
111114 ])
112- var { container, content } = api.app.html.scroller({ prepend: searchHeader })
115 + const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
116 + const { container, content } = api.app.html.scroller({ prepend: [searchHeader, filterMenu] })
113117 container.id = path // helps tabs find this tab
114118
115119 function renderMsg (msg) {
116120 var el = api.message.html.render(msg)
117121 highlight(el, createOrRegExp(query))
118122 return el
119123 }
120124
121- pull(
122- api.sbot.pull.log({old: false}),
123- pull.filter(matchesQuery),
124- Scroller(container, content, renderMsg, true, false)
125- )
126125
127- pull(
128- next(api.sbot.pull.search, {query: queryStr, reverse: true, limit: 500, live: false}),
129- fallback((err) => {
130- if (err === true) {
131- search.fulltext.isDone.set(true)
132- } else if (/^no source/.test(err.message)) {
133- search.isLinear.set(true)
134- return pull(
135- next(api.sbot.pull.log, {reverse: true, limit: 500, live: false}),
136- pull.through(() => search.linear.checked.set(search.linear.checked() + 1)),
137- pull.filter(matchesQuery)
138- )
139- }
140- }),
141- pull.through(() => search.matches.set(search.matches() + 1)),
142- Scroller(container, content, renderMsg, false, false)
143- )
144126
127 + function draw () {
128 + resetFeed({ container, content })
129 +
130 + pull(
131 + api.sbot.pull.log({old: false}),
132 + pull.filter(matchesQuery),
133 + filterUpThrough(),
134 + Scroller(container, content, renderMsg, true, false)
135 + )
136 +
137 + pull(
138 + next(api.sbot.pull.search, {query: queryStr, reverse: true, limit: 500, live: false}),
139 + fallback((err) => {
140 + if (err === true) {
141 + search.fulltext.isDone.set(true)
142 + } else if (/^no source/.test(err.message)) {
143 + search.isLinear.set(true)
144 + return pull(
145 + next(api.sbot.pull.log, {reverse: true, limit: 500, live: false}),
146 + pull.through(() => search.linear.checked.set(search.linear.checked() + 1)),
147 + pull.filter(matchesQuery)
148 + )
149 + }
150 + }),
151 + filterDownThrough(),
152 + pull.through(() => search.matches.set(search.matches() + 1)),
153 + Scroller(container, content, renderMsg, false, false)
154 + )
155 + }
156 +
157 + draw()
158 +
145159 return container
146160 }
147161 }
148162

Built with git-ssb-web