Commit 9586c1b4818398af637ad0672a2db42e5487ab29
disable bits that are not strictly needed
Dominic Tarr committed on 8/14/2017, 12:28:34 PMParent: 7d3eedbfb460afbb17537a609239a3d957ecc662
Files changed
state/obs.js | changed |
state/obs.js | ||
---|---|---|
@@ -21,12 +21,14 @@ | ||
21 | 21 | |
22 | 22 | return nest('state.obs.threads', function buildThreadObs() { |
23 | 23 | if(threadsObs) return threadsObs |
24 | 24 | |
25 | - var initial | |
26 | - try { initial = JSON.parse(localStorage.threadsState) } | |
27 | - catch (_) { } | |
25 | +// var initial | |
26 | +// try { initial = JSON.parse(localStorage.threadsState) } | |
27 | +// catch (_) { } | |
28 | +// | |
28 | 29 | |
30 | + initial = {} | |
29 | 31 | var lastTimestamp = initial ? initial.last : Date.now() |
30 | 32 | var firstTimestamp = initial ? initial.first || Date.now() : Date.now() |
31 | 33 | |
32 | 34 | function unbox () { |
@@ -54,29 +56,11 @@ | ||
54 | 56 | //value recovered from localStorage |
55 | 57 | initial |
56 | 58 | ) |
57 | 59 | |
58 | - threadsObs(function (threadsState) { | |
59 | - if(threadsState.ended && threadsState.ended !== true) | |
60 | - console.error('threadObs error:', threadsState.ended) | |
61 | - }) | |
62 | - | |
63 | - var timer | |
64 | - //keep localStorage up to date | |
65 | - threadsObs(function (threadsState) { | |
66 | - if(timer) return | |
67 | - timer = setTimeout(function () { | |
68 | - timer = null | |
69 | - threadsState.last = lastTimestamp | |
70 | - console.log('save state') | |
71 | - localStorage.threadsState = JSON.stringify(threadsState) | |
72 | - }, 1000) | |
73 | - }) | |
74 | - | |
75 | 60 | //stream live messages. this *should* work. |
76 | 61 | //there is no back pressure on new events |
77 | 62 | //only a show more on the top (currently) |
78 | - | |
79 | 63 | pull( |
80 | 64 | Next(function () { |
81 | 65 | return api.sbot.pull.log({limit: 500, gt: firstTimestamp, live: true}) |
82 | 66 | }), |
@@ -86,8 +70,29 @@ | ||
86 | 70 | threadsObs.set(threadReduce(threadsObs.value, data)) |
87 | 71 | }) |
88 | 72 | ) |
89 | 73 | |
74 | + | |
75 | + threadsObs(function (threadsState) { | |
76 | + if(threadsState.ended && threadsState.ended !== true) | |
77 | + console.error('threadObs error:', threadsState.ended) | |
78 | + }) | |
79 | + | |
80 | +// var timer | |
81 | +// //keep localStorage up to date | |
82 | +// threadsObs(function (threadsState) { | |
83 | +// if(timer) return | |
84 | +// timer = setTimeout(function () { | |
85 | +// timer = null | |
86 | +// threadsState.last = lastTimestamp | |
87 | +// console.log('save state') | |
88 | +// localStorage.threadsState = JSON.stringify(threadsState) | |
89 | +// }, 1000) | |
90 | +// }) | |
91 | +// | |
92 | + | |
90 | 93 | return threadsObs |
91 | 94 | }) |
92 | 95 | } |
93 | 96 | |
97 | + | |
98 | + |
Built with git-ssb-web