Commit 07b744af8d044a6cc9f20deae76832329371760f
tidy up unused obs.following code
mix irving committed on 9/14/2017, 9:21:38 PMParent: 5d2368fbb63ed026f1ec95ac3ccf520f21aab635
Files changed
contact/obs.js | changed |
contact/obs.js | ||
---|---|---|
@@ -20,10 +20,10 @@ | ||
20 | 20 | return nest({ |
21 | 21 | 'contact.obs': { |
22 | 22 | following: following, |
23 | 23 | followers: followers, |
24 | - blocking: (id) => values(get(id), 'blocking', true), | |
25 | - blockers: (id) => values(get(id), 'blockers', true), | |
24 | + // blocking: (id) => values(get(id), 'blocking', true), | |
25 | + // blockers: (id) => values(get(id), 'blockers', true), | |
26 | 26 | }, |
27 | 27 | 'sbot.hook.publish': function (msg) { |
28 | 28 | // TODO ??? |
29 | 29 | // if (isContact(msg)) { |
@@ -79,26 +79,13 @@ | ||
79 | 79 | if (cache[next][key]) return [...sofar, next] |
80 | 80 | else return sofar |
81 | 81 | }, []) |
82 | 82 | }) |
83 | - // var obs = computed(cache.keys, keys => { | |
84 | - // return keys | |
85 | - // .reduce((sofar, next) => { | |
86 | - // if (get(next)()[key]) return [...sofar, next] | |
87 | - // else return sofar | |
88 | - // }, []) | |
89 | - // }) | |
90 | 83 | |
91 | 84 | obs.sync = sync |
92 | 85 | return obs |
93 | 86 | } |
94 | 87 | |
95 | - function values (state, key, compare) { | |
96 | - var obs = computed([state, key, compare], getIds) | |
97 | - obs.sync = sync | |
98 | - return obs | |
99 | - } | |
100 | - | |
101 | 88 | function loadCache () { |
102 | 89 | pull( |
103 | 90 | api.sbot.pull.stream(sbot => sbot.friends.stream({live: true})), |
104 | 91 | pull.drain(item => { |
@@ -113,9 +100,8 @@ | ||
113 | 100 | ) |
114 | 101 | } |
115 | 102 | |
116 | 103 | function update (sourceId, values) { |
117 | - // ssb-contacts: values = { following, followers, blocking, blockers, ... } | |
118 | 104 | // ssb-friends: values = { |
119 | 105 | // keyA: true|null|false (friend, neutral, block) |
120 | 106 | // keyB: true|null|false (friend, neutral, block) |
121 | 107 | // } |
@@ -127,19 +113,9 @@ | ||
127 | 113 | lastState[targetId] = values[targetId] |
128 | 114 | changed = true |
129 | 115 | } |
130 | 116 | } |
131 | - // for (var key in values) { | |
132 | 117 | |
133 | - // var valuesForKey = lastState[key] = lastState[key] || {} | |
134 | - // for (var dest in values[key]) { | |
135 | - // var value = values[key][dest] | |
136 | - // if (!valuesForKey[dest] || value[1] > valuesForKey[dest][1] || !values[1] || !valuesForKey[dest[1]]) { | |
137 | - // valuesForKey[dest] = value | |
138 | - // changed = true | |
139 | - // } | |
140 | - // } | |
141 | - // } | |
142 | 118 | if (changed) { |
143 | 119 | state.set(lastState) |
144 | 120 | } |
145 | 121 | } |
@@ -156,19 +132,8 @@ | ||
156 | 132 | return cache.get(id) |
157 | 133 | } |
158 | 134 | } |
159 | 135 | |
160 | -function getIds (state, key, compare) { | |
161 | - var result = new Set() | |
162 | - if (state[key]) { | |
163 | - for (var dest in state[key]) { | |
164 | - if (state[key][dest][0] === compare) { | |
165 | - result.add(dest) | |
166 | - } | |
167 | - } | |
168 | - } | |
169 | - return result | |
170 | -} | |
171 | - | |
172 | 136 | function isContact (msg) { |
173 | 137 | return msg.value && msg.value.content && msg.value.content.type === 'contact' |
174 | 138 | } |
139 | + |
Built with git-ssb-web