git ssb

7+

dinoworm 🐛 / patchcore



Commit 295e5e4e33bfb464d2d6686f8eeb65b0c9451882

add vote message_renderer

Matt McKegg committed on 2/12/2017, 3:46:11 PM
Parent: 2518a36ed6ec12157e76d3fbeda7e4d59a98cf57

Files changed

plugs/message_render/vote.jsadded
plugs/message_render/vote.jsView
@@ -1,0 +1,32 @@
1 +var h = require('mutant/h')
2 +
3 +exports.needs = {
4 + message_layout: 'first',
5 + message_link: 'first',
6 + markdown: 'first'
7 +}
8 +
9 +exports.gives = {
10 + message_render: true
11 +}
12 +
13 +exports.create = function (api) {
14 + return {
15 + message_render
16 + }
17 +
18 + function message_render (msg) {
19 + if (msg.value.content.type !== 'vote') return
20 + return api.message_layout(msg, {
21 + content: render_vote(msg),
22 + mini: true
23 + })
24 + }
25 +
26 + function render_vote (msg) {
27 + var link = msg.value.content.vote.link
28 + return [
29 + msg.value.content.vote.value > 0 ? 'dug' : 'undug', ' ', api.message_link(link)
30 + ]
31 + }
32 +}

Built with git-ssb-web