git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 90dfad001a91b412a745a9cad0dccf4a3ef49dc2

fixed empty nodes being inserted on `friends` tab. this was really slowing the browser down and adding a bunch of unnecessary nodes to the DOM.

austinfrey committed on 4/10/2019, 7:59:26 PM
Parent: 19f91ba3faa6b3502b74819961f35be8faedccb3

Files changed

mvd/render.jschanged
mvd/views.jschanged
package.jsonchanged
mvd/render.jsView
@@ -293,9 +293,9 @@
293293
294294 pull(
295295 sbot.query({query: [{$filter: {value: { content: {type: 'label', link: msg.key}}}}], limit: 100, live: true}),
296296 pull.drain(function (labels){
297- console.log(labels)
297 + //console.log(labels)
298298 if (labels.value){
299299 message.appendChild(h('span', ' ', h('mark', h('a', {href: '#label/' + labels.value.content.label}, labels.value.content.label))))
300300
301301 }
mvd/views.jsView
@@ -1,5 +1,6 @@
1-var pull = require('pull-stream')
1 +var {pull, filter} = require('pull-stream')
2 +var para = require('pull-paramap')
23 var human = require('human-time')
34 var sbot = require('./scuttlebot')
45 var hyperscroll = require('hyperscroll')
56 var hyperfile = require('hyperfile')
@@ -77,19 +78,9 @@
7778 pull.filter(function (msg) {
7879 return ((msg.value.private == true) || ('string' == typeof msg.value.content))
7980 }),
8081 pull.map(function (msg) {
81- /*if (msg.value.private != true) {
82- var unboxed = ssbKeys.unbox(msg.value.content, keys)
83- if (unboxed) {
84- msg.value.content = unboxed
85- msg.value.private = true
86- return render(msg)
87- } else {
88- return render(msg)
89- }
90- } else {return render(msg)}*/
91- return render(msg)
82 + return render(msg)
9283 })
9384 )
9485 }
9586
@@ -101,9 +92,9 @@
10192 query: [
10293 {
10394 $filter: {
10495 value: {
105- content: {type: 'post'},
96 + content: {type: 'post'}, // only exists in posts i can read
10697 timestamp: {
10798 $gt: 0
10899 }
109100 }
@@ -117,81 +108,12 @@
117108 createStream({
118109 limit: 100,
119110 old: false,
120111 live: true,
121- query: [{$filter: { value: { timestamp: { $gt: 0 }}}}]
112 + query: [{$filter: { value: { content: {type: 'post'}, timestamp: { $gt: 0 }}}}]
122113 }),
123114 stream.top(content)
124115 )
125-
126-
127- /*function createStream (opts) {
128- return pull(
129- Next(sbot.query, opts, ['value', 'timestamp']),
130- pull.map(function (msg) {
131- if (msg.value) {
132- if (msg.value.timestamp > Date.now()) {
133- return h('div.future')
134- } else {
135- return render(msg)
136- }
137- }
138- })
139- )
140- }
141-
142- pull(
143- createStream({
144- limit: 10,
145- reverse: true,
146- live: false,
147- query: [{$filter: { value: { private: true, timestamp: { $gt: 0 }}}}]
148- }),
149- stream.bottom(content)
150- )
151-
152- pull(
153- createStream({
154- limit: 10,
155- old: false,
156- live: true,
157- query: [{$filter: { value: { private: true, timestamp: { $gt: 0 }}}}]
158- }),
159- stream.top(content)
160- )*/
161-
162-
163- /*function createStream (opts) {
164- return pull(
165- More(sbot.createLogStream, opts),
166- pull.filter(function (msg) {
167- return 'string' == typeof msg.value.content
168- }),
169- pull.filter(function (msg) {
170- var unboxed = ssbKeys.unbox(msg.value.content, keys)
171- if (unboxed) {
172- msg.value.content = unboxed
173- msg.value.private = true
174- return msg
175- } else {
176- return msg
177- }
178- }),
179- pull.map(function (msg) {
180- return render(msg)
181- })
182- )
183- }
184-
185- pull(
186- createStream({old: false, limit: 1000}),
187- stream.top(content)
188- )
189-
190- pull(
191- createStream({reverse: true, live: false, limit: 1000}),
192- stream.bottom(content)
193- )*/
194116 }
195117
196118 var queueStream = function () {
197119 var content = h('div.content')
@@ -572,17 +494,20 @@
572494
573495 function createStream (opts) {
574496 return pull(
575497 Next(sbot.query, opts, ['value', 'timestamp']),
576- pull.map(function (msg) {
498 + para(function (msg, cb) {
577499 sbot.friends.get({source: src, dest: msg.value.author}, function (err, data) {
500 + if (err) cb(err)
578501 if (data === true) {
579- return content.appendChild(render(msg))
580- console.log(msg)
502 + return cb(null, render(msg))
581503 } else {
582- return content.appendChild(h('div'))
504 + return cb(null, false)
583505 }
584506 })
507 + }),
508 + filter(function (data) {
509 + return data !== false
585510 })
586511 )
587512 }
588513
@@ -612,9 +537,10 @@
612537 if (msg.value) {
613538 if (msg.value.timestamp > Date.now()) {
614539 return h('div.future')
615540 } else {
616- return render(msg)
541 + var node = render(msg)
542 + return node
617543 }
618544 }
619545 })
620546 )
package.jsonView
@@ -39,8 +39,9 @@
3939 "patch-package": "^6.1.0",
4040 "pull-file": "^1.1.0",
4141 "pull-more": "^1.1.0",
4242 "pull-next-query": "^1.0.0",
43 + "pull-paramap": "^1.2.2",
4344 "pull-reconnect": "0.0.3",
4445 "pull-stream": "^3.6.9",
4546 "pull-stringify": "^2.0.0",
4647 "pull-through": "^1.0.18",

Built with git-ssb-web