git ssb

2+

mixmix / ticktack



Commit 4dbb2a6693e61517c65a6eb549c9f0d8acf437b7

there is a bug with live channel streams, using this work-around for now

Dominic Tarr committed on 8/14/2017, 12:58:40 PM
Parent: f72dd7d62b01eb6de4d424c0a1d47a4814ef6599

Files changed

state/obs.jschanged
state/obs.jsView
@@ -18,24 +18,25 @@
1818
1919 exports.create = function (api) {
2020 var threadsObs
2121
22- function createStateObs (reduce, createStream, opts, initial) {
23- var lastTimestamp = opts.last || Date.now()
24- var firstTimestamp = opts.first || Date.now()
22+ function createStateObs (threadReduce, createStream, initial) {
23+ var lastTimestamp = initial ? initial.last : Date.now()
24+ var firstTimestamp = initial ? initial.first || Date.now() : Date.now()
2525
2626 function unbox () {
2727 return pull(
2828 pull.map(function (data) {
29+// lastTimestamp = data.timestamp
2930 if(isObject(data.value.content)) return data
3031 return api.message.sync.unbox(data)
3132 }),
3233 pull.filter(Boolean)
3334 )
3435 }
3536
36- var obs = PullObv(
37- reduce,
37+ var threadsObs = PullObv(
38+ threadReduce,
3839 pull(
3940 Next(function () {
4041 return createStream({reverse: true, limit: 500, lt: lastTimestamp})
4142 }),
@@ -57,13 +58,13 @@
5758 }),
5859 pull.drain(function (data) {
5960 if(data.sync) return
6061 firstTimestamp = data.timestamp
61- obs.set(reduce(threadsObs.value, data))
62+ threadsObs.set(threadReduce(threadsObs.value, data))
6263 })
6364 )
6465
65- return obs
66+ return threadsObs
6667 }
6768
6869
6970 return nest('state.obs.threads', function buildThreadObs() {
@@ -75,9 +76,9 @@
7576 //
7677
7778 initial = {}
7879
79- threadsObs = createStateObs(threadReduce, api.sbot.pull.log, initial, {})
80+ threadsObs = createStateObs(threadReduce, api.sbot.pull.log, initial)
8081
8182 threadsObs(function (threadsState) {
8283 if(threadsState.ended && threadsState.ended !== true)
8384 console.error('threadObs error:', threadsState.ended)
@@ -102,7 +103,4 @@
102103
103104
104105
105106
106-
107-
108-

Built with git-ssb-web