From f51983b5e78e1dd23ae6482b97679a5618560429 Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 25 Nov 2017 20:07:18 -0700 Subject: Use ssb-contact again, with block(er)s It streams the friends list rather than buffering it --- lib/serve.js | 59 +++++++++++++++++++++++------------------------------------ 1 file changed, 23 insertions(+), 36 deletions(-) (limited to 'lib/serve.js') diff --git a/lib/serve.js b/lib/serve.js index e05acd5..47bc7c2 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -797,10 +797,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(ids) { + function renderFriendsList() { 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) + '…' @@ -815,40 +815,27 @@ Serve.prototype.contacts = function (path) { ) } - 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') - }) - ) - }) + 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), + ph('h4', {}, 'Blocks'), + renderFriendsList()(contacts.blocks), + ph('h4', {}, 'Blocked by'), + renderFriendsList()(contacts.blockers) + ]) + ]), + this.wrapPage('contacts: ' + id), + this.respondSink(200, { + 'Content-Type': ctype('html') + }) + ) } Serve.prototype.about = function (path) { -- cgit v1.2.3