diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-12-05 14:33:53 -0800 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-12-05 15:10:53 -0800 |
commit | 00885846f2c98059a4b95b2d18b4a4a8f22f7901 (patch) | |
tree | 1e62d9daca99798042356b9b470880fcc2e7d503 /lib | |
parent | 9898ecb4b08704b162719cac5810ce095a96b545 (diff) | |
download | patchfoo-00885846f2c98059a4b95b2d18b4a4a8f22f7901.tar.gz patchfoo-00885846f2c98059a4b95b2d18b4a4a8f22f7901.zip |
List friends following feed
Diffstat (limited to 'lib')
-rw-r--r-- | lib/app.js | 5 | ||||
-rw-r--r-- | lib/render.js | 18 | ||||
-rw-r--r-- | lib/serve.js | 61 |
3 files changed, 54 insertions, 30 deletions
@@ -56,6 +56,7 @@ function App(sbot, config) { this.render = new Render(this, this.opts) this.git = new Git(this) + this.contacts = new Contacts(this.sbot) this.monitorBlobWants() } @@ -464,10 +465,6 @@ App.prototype.streamMyChannels = function (id, opts) { ) } -App.prototype.createContactStreams = function (id) { - return new Contacts(this.sbot).createContactStreams(id) -} - function compareVoted(a, b) { return b.value - a.value } diff --git a/lib/render.js b/lib/render.js index ed011bb..95c8c50 100644 --- a/lib/render.js +++ b/lib/render.js @@ -562,3 +562,21 @@ Render.prototype.npmPrebuildMention = function (link, opts, cb) { ])) }) } + +Render.prototype.friendsList = function (prefix) { + prefix = prefix || '/' + var self = this + 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.toUrl(prefix + id)}, name)) + }) + }, 8), + pull.map(function (el) { + return [el, ' '] + }), + pull.flatten(), + pull.map(u.toHTML) + ) +} 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 ]) |