Commit d6f54a07556edba2c3504ce40341185efe763303
drop that junk folder!
mix irving committed on 7/12/2018, 8:42:32 AMParent: cc09b1cc7b68ac05f092c0ea8eb28bbab31e8e23
Files changed
app/page/notifications.js | changed |
app/page/private.js | changed |
app/page/profile.js | changed |
app/page/search.js | changed |
junk/next-stepper.js | deleted |
app/page/notifications.js | ||
---|---|---|
@@ -1,11 +1,10 @@ | ||
1 | 1 … | const nest = require('depnest') |
2 | 2 … | const { h } = require('mutant') |
3 | 3 … | const pull = require('pull-stream') |
4 | 4 … | const Scroller = require('pull-scroll') |
5 … | +const next = require('pull-next-step') | |
5 | 6 … | |
6 | -const next = require('../../junk/next-stepper') | |
7 | - | |
8 | 7 … | exports.gives = nest({ |
9 | 8 … | 'app.html.menuItem': true, |
10 | 9 … | 'app.page.notifications': true |
11 | 10 … | }) |
app/page/private.js | |||
---|---|---|---|
@@ -2,11 +2,10 @@ | |||
2 | 2 … | const { h } = require('mutant') | |
3 | 3 … | const pull = require('pull-stream') | |
4 | 4 … | const Scroller = require('pull-scroll') | |
5 | 5 … | const ref = require('ssb-ref') | |
6 … | +const next = require('pull-next-step') | ||
6 | 7 … | ||
7 | -const next = require('../../junk/next-stepper') | ||
8 | - | ||
9 | 8 … | exports.gives = nest({ | |
10 | 9 … | 'app.html.menuItem': true, | |
11 | 10 … | 'app.page.private': true | |
12 | 11 … | }) |
app/page/profile.js | ||
---|---|---|
@@ -1,11 +1,10 @@ | ||
1 | 1 … | const nest = require('depnest') |
2 | 2 … | const Scroller = require('pull-scroll') |
3 | 3 … | const pull = require('pull-stream') |
4 | 4 … | const { h, watch } = require('mutant') |
5 … | +const next = require('pull-next-query') | |
5 | 6 … | |
6 | -const next = require('../../junk/next-stepper') | |
7 | - | |
8 | 7 … | exports.gives = nest({ |
9 | 8 … | 'app.html.menuItem': true, |
10 | 9 … | 'app.page.profile': true |
11 | 10 … | }) |
@@ -17,9 +16,9 @@ | ||
17 | 16 … | 'app.sync.goTo': 'first', |
18 | 17 … | 'contact.html.relationships': 'first', |
19 | 18 … | 'keys.sync.id': 'first', |
20 | 19 … | 'message.html.render': 'first', |
21 | - 'sbot.pull.userFeed': 'first' | |
20 … | + 'sbot.pull.stream': 'first' | |
22 | 21 … | }) |
23 | 22 … | |
24 | 23 … | exports.create = function (api) { |
25 | 24 … | return nest({ |
@@ -46,18 +45,27 @@ | ||
46 | 45 … | ]) |
47 | 46 … | |
48 | 47 … | var { container, content } = api.app.html.scroller({ prepend: profile }) |
49 | 48 … | |
49 … | + const source = (opts) => api.sbot.pull.stream(s => next(s.query.read, opts, ['value', 'timestamp'])) | |
50 … | + const query = [{ | |
51 … | + $filter: { | |
52 … | + value: { | |
53 … | + timestamp: { $gt: 0 }, | |
54 … | + author: id | |
55 … | + } | |
56 … | + } | |
57 … | + }] | |
58 … | + | |
50 | 59 … | pull( |
51 | - api.sbot.pull.userFeed({id: id, old: false, live: true}), | |
60 … | + source({ query, live: true, old: false }), | |
52 | 61 … | Scroller(container, content, api.message.html.render, true, false) |
53 | 62 … | ) |
54 | 63 … | |
55 | 64 … | // how to handle when have scrolled past the start??? |
56 | 65 … | |
57 | 66 … | pull( |
58 | - next(api.sbot.pull.userFeed, { id: id, reverse: true, limit: 50, live: false }, ['value', 'sequence']), | |
59 | - // pull.through(console.log.bind(console)), | |
67 … | + source({ query, reverse: true, limit: 50 }), | |
60 | 68 … | Scroller(container, content, api.message.html.render, false, false) |
61 | 69 … | ) |
62 | 70 … | |
63 | 71 … | watch(api.about.obs.name(id), name => { container.title = '@' + name }) |
app/page/search.js | ||
---|---|---|
@@ -1,12 +1,11 @@ | ||
1 | 1 … | const nest = require('depnest') |
2 | 2 … | const { h, Struct, Value, when, computed } = require('mutant') |
3 | 3 … | const pull = require('pull-stream') |
4 … | +const next = require('pull-next-step') | |
4 | 5 … | const Scroller = require('pull-scroll') |
5 | 6 … | const TextNodeSearcher = require('text-node-searcher') |
6 | 7 … | |
7 | -const next = require('../../junk/next-stepper') | |
8 | - | |
9 | 8 … | exports.gives = nest('app.page.search') |
10 | 9 … | |
11 | 10 … | exports.needs = nest({ |
12 | 11 … | 'app.html.filter': 'first', |
@@ -126,9 +125,9 @@ | ||
126 | 125 … | Scroller(container, content, renderMsg, true, false) |
127 | 126 … | ) |
128 | 127 … | |
129 | 128 … | pull( |
130 | - api.sbot.pull.stream(sbot => next(sbot.search.query, {query, limit: 500 })), | |
129 … | + api.sbot.pull.stream(sbot => next(sbot.search.query, { query, limit: 500 })), | |
131 | 130 … | fallback((err) => { |
132 | 131 … | if (err === true) { |
133 | 132 … | search.fulltext.isDone.set(true) |
134 | 133 … | } else if (/^no source/.test(err.message)) { |
junk/next-stepper.js | ||
---|---|---|
@@ -1,57 +1,0 @@ | ||
1 | -const pull = require('pull-stream') | |
2 | -const Next = require('pull-next') | |
3 | - | |
4 | -module.exports = nextStepper | |
5 | - | |
6 | -// TODO - this should be another module? | |
7 | - | |
8 | -function nextStepper (createStream, opts, property, range) { | |
9 | - range = range || (opts.reverse ? 'lt' : 'gt') | |
10 | - property = property || 'timestamp' | |
11 | - | |
12 | - var last = null | |
13 | - var count = -1 | |
14 | - | |
15 | - return Next(function () { | |
16 | - if (last) { | |
17 | - if (count === 0) return | |
18 | - var value = opts[range] = get(last, property) | |
19 | - if (value == null) return | |
20 | - last = null | |
21 | - } | |
22 | - return pull( | |
23 | - createStream(clone(opts)), | |
24 | - pull.through(function (msg) { | |
25 | - count++ | |
26 | - if (!msg.sync) { | |
27 | - last = msg | |
28 | - } | |
29 | - }, function (err) { | |
30 | - // retry on errors... | |
31 | - if (err) { | |
32 | - count = -1 | |
33 | - return count | |
34 | - } | |
35 | - // end stream if there were no results | |
36 | - if (last == null) last = {} | |
37 | - }) | |
38 | - ) | |
39 | - }) | |
40 | -} | |
41 | - | |
42 | -function get (obj, path) { | |
43 | - if (!obj) return undefined | |
44 | - if (typeof path === 'string') return obj[path] | |
45 | - if (Array.isArray(path)) { | |
46 | - for (var i = 0; obj && i < path.length; i++) { | |
47 | - obj = obj[path[i]] | |
48 | - } | |
49 | - return obj | |
50 | - } | |
51 | -} | |
52 | - | |
53 | -function clone (obj) { | |
54 | - var _obj = {} | |
55 | - for (var k in obj) _obj[k] = obj[k] | |
56 | - return _obj | |
57 | -} |
Built with git-ssb-web