git ssb

16+

Dominic / patchbay



Commit d6f54a07556edba2c3504ce40341185efe763303

drop that junk folder!

mix irving committed on 7/12/2018, 8:42:32 AM
Parent: cc09b1cc7b68ac05f092c0ea8eb28bbab31e8e23

Files changed

app/page/notifications.jschanged
app/page/private.jschanged
app/page/profile.jschanged
app/page/search.jschanged
junk/next-stepper.jsdeleted
app/page/notifications.jsView
@@ -1,11 +1,10 @@
11 const nest = require('depnest')
22 const { h } = require('mutant')
33 const pull = require('pull-stream')
44 const Scroller = require('pull-scroll')
5 +const next = require('pull-next-step')
56
6-const next = require('../../junk/next-stepper')
7-
87 exports.gives = nest({
98 'app.html.menuItem': true,
109 'app.page.notifications': true
1110 })
app/page/private.jsView
@@ -2,11 +2,10 @@
22 const { h } = require('mutant')
33 const pull = require('pull-stream')
44 const Scroller = require('pull-scroll')
55 const ref = require('ssb-ref')
6 +const next = require('pull-next-step')
67
7-const next = require('../../junk/next-stepper')
8-
98 exports.gives = nest({
109 'app.html.menuItem': true,
1110 'app.page.private': true
1211 })
app/page/profile.jsView
@@ -1,11 +1,10 @@
11 const nest = require('depnest')
22 const Scroller = require('pull-scroll')
33 const pull = require('pull-stream')
44 const { h, watch } = require('mutant')
5 +const next = require('pull-next-query')
56
6-const next = require('../../junk/next-stepper')
7-
87 exports.gives = nest({
98 'app.html.menuItem': true,
109 'app.page.profile': true
1110 })
@@ -17,9 +16,9 @@
1716 'app.sync.goTo': 'first',
1817 'contact.html.relationships': 'first',
1918 'keys.sync.id': 'first',
2019 'message.html.render': 'first',
21- 'sbot.pull.userFeed': 'first'
20 + 'sbot.pull.stream': 'first'
2221 })
2322
2423 exports.create = function (api) {
2524 return nest({
@@ -46,18 +45,27 @@
4645 ])
4746
4847 var { container, content } = api.app.html.scroller({ prepend: profile })
4948
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 +
5059 pull(
51- api.sbot.pull.userFeed({id: id, old: false, live: true}),
60 + source({ query, live: true, old: false }),
5261 Scroller(container, content, api.message.html.render, true, false)
5362 )
5463
5564 // how to handle when have scrolled past the start???
5665
5766 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 }),
6068 Scroller(container, content, api.message.html.render, false, false)
6169 )
6270
6371 watch(api.about.obs.name(id), name => { container.title = '@' + name })
app/page/search.jsView
@@ -1,12 +1,11 @@
11 const nest = require('depnest')
22 const { h, Struct, Value, when, computed } = require('mutant')
33 const pull = require('pull-stream')
4 +const next = require('pull-next-step')
45 const Scroller = require('pull-scroll')
56 const TextNodeSearcher = require('text-node-searcher')
67
7-const next = require('../../junk/next-stepper')
8-
98 exports.gives = nest('app.page.search')
109
1110 exports.needs = nest({
1211 'app.html.filter': 'first',
@@ -126,9 +125,9 @@
126125 Scroller(container, content, renderMsg, true, false)
127126 )
128127
129128 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 })),
131130 fallback((err) => {
132131 if (err === true) {
133132 search.fulltext.isDone.set(true)
134133 } else if (/^no source/.test(err.message)) {
junk/next-stepper.jsView
@@ -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