aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-12-05 14:33:53 -0800
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-12-05 15:10:53 -0800
commit00885846f2c98059a4b95b2d18b4a4a8f22f7901 (patch)
tree1e62d9daca99798042356b9b470880fcc2e7d503
parent9898ecb4b08704b162719cac5810ce095a96b545 (diff)
downloadpatchfoo-00885846f2c98059a4b95b2d18b4a4a8f22f7901.tar.gz
patchfoo-00885846f2c98059a4b95b2d18b4a4a8f22f7901.zip
List friends following feed
-rw-r--r--lib/app.js5
-rw-r--r--lib/render.js18
-rw-r--r--lib/serve.js61
-rw-r--r--package-lock.json4
-rw-r--r--package.json2
5 files changed, 57 insertions, 33 deletions
diff --git a/lib/app.js b/lib/app.js
index da41459..643b317 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -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
])
diff --git a/package-lock.json b/package-lock.json
index 00a0bcb..565964a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1054,8 +1054,8 @@
}
},
"ssb-contact": {
- "version": "1.1.0",
- "resolved": "http://localhost:8989/blobs/get/&wU1gwlBbfFf8KL1Y+gBAYi7WapYmN2fg8ODKTpvfcbM=.sha256",
+ "version": "1.2.0",
+ "resolved": "http://localhost:8989/blobs/get/&V4bNrv533a7pKfPxw7Ok92hNWBN+eCbyybmi8cGMzrM=.sha256",
"requires": {
"pull-defer": "0.2.2",
"pull-many": "1.0.8",
diff --git a/package.json b/package.json
index 2dabe70..8f4f503 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
"pull-reader": "^1.2.9",
"pull-stream": "^3.5.0",
"ssb-client": "http://localhost:8989/blobs/get/&EAaUpI+wrJM5/ly1RqZW0GAEF4PmCAmABBj7e6UIrL0=.sha256",
- "ssb-contact": "^1.1.0",
+ "ssb-contact": "^1.2.0",
"ssb-marked": "^0.7.1",
"ssb-mentions": "http://localhost:8989/blobs/get/&GKwsJ3ykvOXc24wyNuWBdmnCFpQ+Ltd9ggjoOuOF/Pg=.sha256",
"ssb-sort": "^1.0.0",