aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js55
1 files changed, 36 insertions, 19 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 2bbc80d..e8313f4 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -794,10 +794,10 @@ Serve.prototype.channels = function (ext) {
Serve.prototype.contacts = function (path) {
var self = this
var id = String(path).substr(1)
- var contacts = self.app.createContactStreams(id)
- function renderFriendsList() {
+ function renderFriendsList(ids) {
return pull(
+ pull.values(ids),
paramap(function (id, cb) {
self.app.getAbout(id, function (err, about) {
var name = about && about.name || id.substr(0, 8) + '…'
@@ -812,23 +812,40 @@ Serve.prototype.contacts = function (path) {
)
}
- pull(
- cat([
- ph('section', {}, [
- ph('h3', {}, ['Contacts: ', self.phIdLink(id)]),
- ph('h4', {}, 'Friends'),
- renderFriendsList()(contacts.friends),
- ph('h4', {}, 'Follows'),
- renderFriendsList()(contacts.follows),
- ph('h4', {}, 'Followers'),
- renderFriendsList()(contacts.followers)
- ])
- ]),
- this.wrapPage('contacts: ' + id),
- this.respondSink(200, {
- 'Content-Type': ctype('html')
- })
- )
+ self.app.getContacts(id, function (err, contacts) {
+ if (err) return self.respond(500, err.stack || err)
+ pull(
+ cat([
+ ph('section', {}, [
+ ph('h3', {}, ['Contacts: ', self.phIdLink(id)]),
+ contacts.friends.length ? [
+ ph('h4', {}, 'Friends'),
+ renderFriendsList(contacts.friends),
+ ] : [],
+ contacts.follows.length ? [
+ ph('h4', {}, 'Follows'),
+ renderFriendsList(contacts.follows),
+ ] : [],
+ contacts.followers.length ? [
+ ph('h4', {}, 'Followers'),
+ renderFriendsList(contacts.followers),
+ ] : [],
+ contacts.blocks.length ? [
+ ph('h4', {}, 'Blocks'),
+ renderFriendsList(contacts.blocks),
+ ] : [],
+ contacts.blockers.length ? [
+ ph('h4', {}, 'Blocked by'),
+ renderFriendsList(contacts.blockers),
+ ] : [],
+ ])
+ ]),
+ self.wrapPage('contacts: ' + id),
+ self.respondSink(200, {
+ 'Content-Type': ctype('html')
+ })
+ )
+ })
}
Serve.prototype.about = function (path) {