aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-11-10 07:56:13 +1300
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-11-10 07:56:13 +1300
commitc7b4eb97124284b5c2f9d27a78fbcd83abf3d88a (patch)
tree42e42fcadede049d791937022a14ac0d60a85eba /lib/serve.js
parent74da815bd5764df91b69af7e636b34ba7782f2e0 (diff)
downloadpatchfoo-c7b4eb97124284b5c2f9d27a78fbcd83abf3d88a.tar.gz
patchfoo-c7b4eb97124284b5c2f9d27a78fbcd83abf3d88a.zip
Add block button
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js37
1 files changed, 14 insertions, 23 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 11630e4..6d3786d 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -193,8 +193,11 @@ Serve.prototype.publishContact = function (cb) {
var content = {
type: 'contact',
contact: this.data.contact,
- following: !!this.data.following
}
+ if (this.data.follow) content.following = true
+ if (this.data.block) content.blocking = true
+ if (this.data.unfollow) content.following = false
+ if (this.data.unblock) content.blocking = false
this.publish(content, cb)
}
@@ -1499,20 +1502,6 @@ Serve.prototype.renderIdsList = function () {
)
}
-var relationships = [
- '',
- 'followed',
- 'follows you',
- 'friend'
-]
-
-var relationshipActions = [
- 'follow',
- 'unfollow',
- 'follow back',
- 'unfriend'
-]
-
Serve.prototype.wrapUserFeed = function (isScrolled, id) {
var self = this
var myId = self.app.sbot.id
@@ -1520,11 +1509,10 @@ Serve.prototype.wrapUserFeed = function (isScrolled, id) {
return u.hyperwrap(function (thread, cb) {
var done = multicb({pluck: 1, spread: true})
self.app.getAbout(id, done())
- self.app.getFollow(myId, id, done())
- self.app.getFollow(id, myId, done())
- done(function (err, about, weFollowThem, theyFollowUs) {
+ self.app.getContact(myId, id, done())
+ self.app.getContact(id, myId, done())
+ done(function (err, about, contactToThem, contactFromThem) {
if (err) return cb(err)
- var relationshipI = weFollowThem | theyFollowUs<<1
var done = multicb({pluck: 1, spread: true})
done()(null, [
h('section.ssb-feed',
@@ -1558,13 +1546,16 @@ Serve.prototype.wrapUserFeed = function (isScrolled, id) {
id === myId ? '' : h('tr',
h('td'),
h('td.follow-info', h('form', {action: '', method: 'post'},
- relationships[relationshipI], ' ',
+ contactFromThem ? contactToThem ? 'friend ' : 'follows you ' :
+ contactFromThem === false ? 'blocks you ' : '',
h('input', {type: 'hidden', name: 'action', value: 'contact'}),
h('input', {type: 'hidden', name: 'contact', value: id}),
- h('input', {type: 'hidden', name: 'following',
- value: weFollowThem ? '' : 'following'}),
h('input', {type: 'submit',
- value: relationshipActions[relationshipI]})
+ name: contactToThem ? 'unfollow' : 'follow',
+ value: contactToThem ? 'unfollow' : 'follow'}), ' ',
+ h('input', {type: 'submit',
+ name: contactToThem === false ? 'unblock' : 'block',
+ value: contactToThem === false ? 'unblock' : 'block'})
))
)
]