Commit 50a4cfa4f114b4bccad254905f4fc367dfa2bdc4
replace state effects (getting root messages) with feed.pull.rollup
mix irving committed on 11/28/2017, 1:26:17 AMParent: fb0788760b2ce15437b50ead1e804b650cc19077
Files changed
state/obs.js | changed |
state/obs.js | ||
---|---|---|
@@ -13,9 +13,10 @@ | ||
13 | 13 | exports.needs = nest({ |
14 | 14 | 'message.sync.unbox': 'first', |
15 | 15 | 'sbot.pull.log': 'first', |
16 | 16 | 'sbot.async.get': 'first', |
17 | - 'feed.pull.channel': 'first' | |
17 | + 'feed.pull.channel': 'first', | |
18 | + 'feed.pull.rollup': 'first' | |
18 | 19 | }) |
19 | 20 | |
20 | 21 | exports.create = function (api) { |
21 | 22 | var threadsObs |
@@ -38,29 +39,16 @@ | ||
38 | 39 | }), |
39 | 40 | pull.through(function (data) { |
40 | 41 | lastTimestamp = data.timestamp |
41 | 42 | }), |
42 | - pull.map(unbox), pull.filter(Boolean) | |
43 | + pull.map(unbox), | |
44 | + pull.filter(Boolean), | |
45 | + api.feed.pull.rollup() | |
43 | 46 | ), |
44 | 47 | //value recovered from localStorage |
45 | 48 | initial |
46 | 49 | ) |
47 | 50 | |
48 | - var getting = {} | |
49 | - obs(function (state) { | |
50 | - var effect = state.effect | |
51 | - if(!effect) return | |
52 | - | |
53 | - state.effect = null | |
54 | - if(getting[effect.key]) return | |
55 | - | |
56 | - getting[effect.key] = true | |
57 | - api.sbot.async.get(effect.key, (err, msg) => { | |
58 | - if (!msg) return | |
59 | - obs.set(STATE=reduce(obs.value, unbox({key: effect.key, value: msg}))) | |
60 | - }) | |
61 | - }) | |
62 | - | |
63 | 51 | //stream live messages. this *should* work. |
64 | 52 | //there is no back pressure on new events |
65 | 53 | //only a show more on the top (currently) |
66 | 54 | pull( |
@@ -103,9 +91,9 @@ | ||
103 | 91 | |
104 | 92 | }, |
105 | 93 | |
106 | 94 | 'state.obs.threads': function buildThreadObs() { |
107 | - if(threadsObs) return threadsObs | |
95 | + if (threadsObs) return threadsObs | |
108 | 96 | |
109 | 97 | // DISABLE localStorage cache. mainly disabling this to make debugging the other stuff |
110 | 98 | // easier. maybe re-enable this later? also, should this be for every channel too? not sure. |
111 | 99 |
Built with git-ssb-web