git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 9d1a251cba252c319e6156e7db50a9cbf86c6e71

add button to query blocks/blocked uxers

Ev Bogue committed on 9/13/2018, 5:17:12 PM
Parent: fd958f9e5ebdd7619db1724eadaabc5ff27aa4b4

Files changed

tools.jschanged
views.jschanged
tools.jsView
@@ -12,8 +12,69 @@
1212 var config = require('./config')()
1313
1414 var id = require('./keys').id
1515
16+
17+module.exports.getBlocks = function (src) {
18+ var blocks = h('div.blocks', 'Blocking: ')
19+
20+ pull(
21+ sbot.query({query: [{$filter: { value: { author: src, content: {type: 'contact'}}}}], live: true}),
22+ pull.drain(function (msg) {
23+ if (msg.value) {
24+ if (msg.value.content.blocking == true) {
25+ console.log(msg.value)
26+ var gotIt = document.getElementById('blocks:' + msg.value.content.contact.substring(0, 44))
27+ if (gotIt == null) {
28+ blocks.appendChild(h('a#blocks:'+ msg.value.content.contact.substring(0, 44), {title: avatar.cachedName(msg.value.content.contact).textContent, href: '#' + msg.value.content.contact}, h('span.avatar--small', avatar.cachedImage(msg.value.content.contact))))
29+ }
30+ }
31+ if (msg.value.content.blocking == false) {
32+ var gotIt = document.getElementById('blocks:' + msg.value.content.contact.substring(0, 44))
33+ if (gotIt != null) {
34+ gotIt.outerHTML = ''
35+ }
36+ }
37+ }
38+ })
39+ )
40+
41+ return blocks
42+
43+}
44+
45+module.exports.getBlocked = function (src) {
46+ var blocked = h('div.blocked', 'Blocked by: ')
47+
48+ pull(
49+ sbot.query({query: [{$filter: { value: { content: {type: 'contact', contact: src}}}}], live: true}),
50+ pull.drain(function (msg) {
51+ if (msg.value) {
52+ if (msg.value.content.blocking == true) {
53+ console.log(msg.value)
54+ var gotIt = document.getElementById('blocked:' + msg.value.content.contact.substring(0, 44))
55+ if (gotIt == null) {
56+ blocked.appendChild(h('a#blocked:'+ msg.value.author.substring(0, 44), {title: avatar.cachedName(msg.value.author).textContent, href: '#' + msg.value.author}, h('span.avatar--small', avatar.cachedImage(msg.value.author))))
57+ }
58+ }
59+ if (msg.value.content.blocking == false) {
60+ var gotIt = document.getElementById('blocked:' + msg.value.author.substring(0, 44))
61+ if (gotIt != null) {
62+ gotIt.outerHTML = ''
63+ }
64+ }
65+ }
66+ })
67+ )
68+
69+ return blocked
70+
71+}
72+
73+
74+
75+
76+
1677 module.exports.getFollowing = function (src) {
1778 var followingCount = 0
1879
1980 var following = h('div.following', 'Following: ')
@@ -47,9 +108,8 @@
47108 })
48109 )
49110 return following
50111 }
51-
52112 module.exports.getFollowers = function (src) {
53113 var followerCount = 0
54114
55115 var followers = h('div.followers', 'Followers: ')
views.jsView
@@ -119,9 +119,9 @@
119119 function createStream (opts) {
120120 return pull(
121121 More(sbot.userStream, opts, ['value', 'sequence']),
122122 pull.map(function (msg) {
123- return render(msg)
123+ return render(h('div', msg))
124124 })
125125 )
126126 }
127127
@@ -287,8 +287,17 @@
287287 profile.firstChild.appendChild(tools.getFollowing(src))
288288 profile.firstChild.appendChild(tools.getFollowers(src))
289289 }
290290 }))
291+
292+ buttons.appendChild(h('button.btn', 'Generate blocks', {
293+ onclick: function () {
294+ profile.firstChild.appendChild(tools.getBlocks(src))
295+ profile.firstChild.appendChild(tools.getBlocked(src))
296+ }
297+ }))
298+
299+
291300 }
292301
293302 var msgThread = function (src) {
294303

Built with git-ssb-web