git ssb

9+

cel / ssb-viewer



Commit d09eab73ae3a9d7f447dfafca886750acd04e58d

Count attendees

Jacob Karlsson committed on 7/6/2018, 9:50:18 PM
Parent: d15a09749d2da84b14e512778ae026fad957d7fc

Files changed

index.jschanged
render.jschanged
index.jsView
@@ -397,15 +397,33 @@
397397 }
398398
399399 function addGatheringAbout(msg, cb) {
400400 if (msg.value && msg.value.content.type === 'gathering') {
401- console.log('adding gathering abouts. msg:', msg)
402401 getAbout(msg.key, (err, about) => {
403- if (err) { return cb(err) }
402 + if (err) { cb(err) }
404403
405404 msg.value.content.about = about
406- console.log('about gathering', about)
407- cb(null, msg)
405 +
406 + pull(
407 + sbot.backlinks.read({
408 + query: [{ $filter: {
409 + dest: msg.key,
410 + value: { content: { type: 'about' }},
411 + }}],
412 + index: 'DTA'
413 + }),
414 + //pull.map(o => { console.log('bl:', o.value.content); return o }),
415 + // Only grab messages about attendance
416 + pull.filter(o => o.value.content.attendee !== undefined),
417 + // Filter "can't attend"-messages
418 + pull.filter(o => !o.value.content.attendee.remove),
419 + pull.unique(o => o.value.content.attendee.link),
420 + pull.collect((err, arr) => {
421 + if (err) { cb(err) }
422 + msg.value.content.numberAttending = arr.length
423 + cb(null, msg)
424 + })
425 + )
408426 })
409427 } else {
410428 cb(null, msg)
411429 }
render.jsView
@@ -295,8 +295,11 @@
295295 .call-to-action:hover {
296296 background-color: #748ffc;
297297 border-bottom: 3px solid #4c6ef5;
298298 }
299 + .attending {
300 + text-align: center;
301 + }
299302 </style>
300303 `;
301304
302305 function wrapJSON() {
@@ -523,25 +526,21 @@
523526
524527 return [channel, h('h2', c.title), s];
525528 }
526529 else if (c.type === 'gathering') {
527- return ['id: ' + id,
528- h('div',
529- renderGathering(opts, id, c)
530- )
531- ]
530 + return h('div', renderGathering(opts, id, c))
532531 }
533532 else return renderDefault(c);
534533 }
535534
536535 function renderGathering(opts, id, c) {
537- console.log('opts', opts)
538- console.log('gathering content:', c)
539536 const desc = h('div')
540537 desc.innerHTML = marked(c.about.description, opts.marked)
541538 const image = h('p', h('img', { src: opts.img_base + c.about.image }))
539 + const attending = h('h3.attending', c.numberAttending + ' attending')
542540 return h('section',
543541 [image,
542 + attending,
544543 desc]
545544 )
546545 }
547546

Built with git-ssb-web