From 00885846f2c98059a4b95b2d18b4a4a8f22f7901 Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 5 Dec 2017 14:33:53 -0800 Subject: List friends following feed --- lib/serve.js | 61 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 26 deletions(-) (limited to 'lib/serve.js') diff --git a/lib/serve.js b/lib/serve.js index 5b6aeff..c100f40 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -794,41 +794,29 @@ Serve.prototype.channels = function (ext) { ) } +function renderFriendsList(app) { +} + Serve.prototype.contacts = function (path) { var self = this var id = String(path).substr(1) - var contacts = self.app.createContactStreams(id) - - function renderFriendsList() { - return pull( - paramap(function (id, cb) { - self.app.getAbout(id, function (err, about) { - var name = about && about.name || id.substr(0, 8) + '…' - cb(null, h('a', {href: self.app.render.toUrl('/contacts/' + id)}, name)) - }) - }, 8), - pull.map(function (el) { - return [el, ' '] - }), - pull.flatten(), - pull.map(u.toHTML) - ) - } + var contacts = self.app.contacts.createContactStreams(id) + var render = self.app.render pull( cat([ ph('section', {}, [ ph('h3', {}, ['Contacts: ', self.phIdLink(id)]), ph('h4', {}, 'Friends'), - renderFriendsList()(contacts.friends), + render.friendsList('/contacts/')(contacts.friends), ph('h4', {}, 'Follows'), - renderFriendsList()(contacts.follows), + render.friendsList('/contacts/')(contacts.follows), ph('h4', {}, 'Followers'), - renderFriendsList()(contacts.followers), + render.friendsList('/contacts/')(contacts.followers), ph('h4', {}, 'Blocks'), - renderFriendsList()(contacts.blocks), + render.friendsList('/contacts/')(contacts.blocks), ph('h4', {}, 'Blocked by'), - renderFriendsList()(contacts.blockers) + render.friendsList('/contacts/')(contacts.blockers) ]) ]), this.wrapPage('contacts: ' + id), @@ -1537,6 +1525,21 @@ Serve.prototype.followInfo = function (id, myId) { }) } +Serve.prototype.friendInfo = function (id, myId) { + var first = false + return pull( + this.app.contacts.createFollowedFollowersStream(myId, id), + this.app.render.friendsList(), + pull.map(function (html) { + if (!first) { + first = true + return 'followed by your friends: ' + html + } + return html + }) + ) +} + Serve.prototype.wrapUserFeed = function (isScrolled, id) { var self = this var myId = self.app.sbot.id @@ -1581,10 +1584,16 @@ Serve.prototype.wrapUserFeed = function (isScrolled, id) { ]) ) ]), - isScrolled || id === myId ? '' : ph('tr', [ - ph('td'), - ph('td', {class: 'follow-info'}, self.followInfo(id, myId)) - ]) + isScrolled || id === myId ? '' : [ + ph('tr', [ + ph('td'), + ph('td', {class: 'follow-info'}, self.followInfo(id, myId)) + ]), + ph('tr', [ + ph('td'), + ph('td', self.friendInfo(id, myId)) + ]) + ] ])), thread ]) -- cgit v1.2.3