Count attendees
This commit is contained in:
@@ -398,14 +398,32 @@ exports.init = function (sbot, config) {
|
|||||||
|
|
||||||
function addGatheringAbout(msg, cb) {
|
function addGatheringAbout(msg, cb) {
|
||||||
if (msg.value && msg.value.content.type === 'gathering') {
|
if (msg.value && msg.value.content.type === 'gathering') {
|
||||||
console.log('adding gathering abouts. msg:', msg)
|
|
||||||
getAbout(msg.key, (err, about) => {
|
getAbout(msg.key, (err, about) => {
|
||||||
if (err) { return cb(err) }
|
if (err) { cb(err) }
|
||||||
|
|
||||||
msg.value.content.about = about
|
msg.value.content.about = about
|
||||||
console.log('about gathering', about)
|
|
||||||
|
pull(
|
||||||
|
sbot.backlinks.read({
|
||||||
|
query: [{ $filter: {
|
||||||
|
dest: msg.key,
|
||||||
|
value: { content: { type: 'about' }},
|
||||||
|
}}],
|
||||||
|
index: 'DTA'
|
||||||
|
}),
|
||||||
|
//pull.map(o => { console.log('bl:', o.value.content); return o }),
|
||||||
|
// Only grab messages about attendance
|
||||||
|
pull.filter(o => o.value.content.attendee !== undefined),
|
||||||
|
// Filter "can't attend"-messages
|
||||||
|
pull.filter(o => !o.value.content.attendee.remove),
|
||||||
|
pull.unique(o => o.value.content.attendee.link),
|
||||||
|
pull.collect((err, arr) => {
|
||||||
|
if (err) { cb(err) }
|
||||||
|
msg.value.content.numberAttending = arr.length
|
||||||
cb(null, msg)
|
cb(null, msg)
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
cb(null, msg)
|
cb(null, msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,6 +296,9 @@ var styles = `
|
|||||||
background-color: #748ffc;
|
background-color: #748ffc;
|
||||||
border-bottom: 3px solid #4c6ef5;
|
border-bottom: 3px solid #4c6ef5;
|
||||||
}
|
}
|
||||||
|
.attending {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -524,23 +527,19 @@ function render(opts, id, c) {
|
|||||||
return [channel, h('h2', c.title), s];
|
return [channel, h('h2', c.title), s];
|
||||||
}
|
}
|
||||||
else if (c.type === 'gathering') {
|
else if (c.type === 'gathering') {
|
||||||
return ['id: ' + id,
|
return h('div', renderGathering(opts, id, c))
|
||||||
h('div',
|
|
||||||
renderGathering(opts, id, c)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
else return renderDefault(c);
|
else return renderDefault(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderGathering(opts, id, c) {
|
function renderGathering(opts, id, c) {
|
||||||
console.log('opts', opts)
|
|
||||||
console.log('gathering content:', c)
|
|
||||||
const desc = h('div')
|
const desc = h('div')
|
||||||
desc.innerHTML = marked(c.about.description, opts.marked)
|
desc.innerHTML = marked(c.about.description, opts.marked)
|
||||||
const image = h('p', h('img', { src: opts.img_base + c.about.image }))
|
const image = h('p', h('img', { src: opts.img_base + c.about.image }))
|
||||||
|
const attending = h('h3.attending', c.numberAttending + ' attending')
|
||||||
return h('section',
|
return h('section',
|
||||||
[image,
|
[image,
|
||||||
|
attending,
|
||||||
desc]
|
desc]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user