Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit d3bfb19

Browse files
committed
contacts: shortcut to get values of isFollowing and isBlocking
for when contacts index is behind
1 parent 415b01b commit d3bfb19

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

sbot/contacts.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,27 @@ exports.init = function (ssb, config) {
5454
raw: view,
5555

5656
isFollowing: function ({ source, dest }, cb) {
57-
view.get((err, graph) => {
58-
if (err) return cb(err)
59-
var following = graph && graph[source] && graph[source][dest] === true
60-
cb(null, following)
61-
})
57+
if (values && values[source]) {
58+
cb(null, values[source][dest] === true)
59+
} else {
60+
view.get((err, graph) => {
61+
if (err) return cb(err)
62+
var following = graph && graph[source] && graph[source][dest] === true
63+
cb(null, following)
64+
})
65+
}
6266
},
6367

6468
isBlocking: function ({ source, dest }, cb) {
65-
view.get((err, graph) => {
66-
if (err) return cb(err)
67-
var blocking = graph && graph[source] && graph[source][dest] === false
68-
cb(null, blocking)
69-
})
69+
if (values && values[source]) {
70+
cb(null, values[source][dest] === false)
71+
} else {
72+
view.get((err, graph) => {
73+
if (err) return cb(err)
74+
var blocking = graph && graph[source] && graph[source][dest] === false
75+
cb(null, blocking)
76+
})
77+
}
7078
},
7179

7280
/// return a list of everyone you have blocked privately

0 commit comments

Comments
 (0)