Commit 4f3e54eaa5e60f7e8551798b984fbf3d4e0886c1
fix handling of realtime updates since #33
Matt McKegg committed on 9/29/2017, 9:27:57 AMParent: bb1e475fdd46fa47fff6cd11fbcb7fa4c1157d43
Files changed
contact/obs.js | changed |
contact/obs.js | ||
---|---|---|
@@ -101,14 +101,17 @@ | ||
101 | 101 | function loadCache () { |
102 | 102 | pull( |
103 | 103 | api.sbot.pull.stream(sbot => sbot.friends.stream({live: true})), |
104 | 104 | pull.drain(item => { |
105 | - for (var source in item) { | |
106 | - if (ref.isFeed(source)) update(source, item[source]) | |
107 | - } | |
108 | - | |
109 | 105 | if (!sync()) { |
106 | + // initial dump | |
107 | + for (var source in item) { | |
108 | + if (ref.isFeed(source)) update(source, item[source]) | |
109 | + } | |
110 | 110 | sync.set(true) |
111 | + } else { | |
112 | + // handle realtime updates | |
113 | + update(item.from, {[item.to]: item.value}) | |
111 | 114 | } |
112 | 115 | }) |
113 | 116 | ) |
114 | 117 | } |
Built with git-ssb-web