git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 76e471a1d7f948aaea0a1f022cc8842d66dff10e

add boost button

Ev Bogue committed on 9/19/2018, 4:10:47 PM
Parent: b755159ec8727b3aa0e1d46c6eb1e68b95b771f1

Files changed

compose.jschanged
render.jschanged
compose.jsView
@@ -4,8 +4,9 @@
44 var human = require('human-time')
55 var id = require('./keys').id
66 var mentions = require('ssb-mentions')
77
8+var avatar = require('./avatar')
89 var tools = require('./tools')
910
1011 var mime = require('simple-mime')('application/octect-stream')
1112 var split = require('split-buffer')
@@ -43,10 +44,23 @@
4344 var filesById = {}
4445
4546 var composer = h('div.composer')
4647 var container = h('div.container')
48+ var boostName = avatar.cachedName(opts.boostAuthor)
4749
48- if (opts.mentions) {
50+ if (opts.boostContent) {
51+ var textarea = h('textarea.compose', 'Blah')
52+ var str = opts.boostContent
53+ var lines = str.split("\n")
54+ for(var i=0; i<lines.length; i++) {
55+ lines[i] = "> " + lines[i]
56+ }
57+ var newContent = lines.join("\n")
58+ var content = 'Boosting: ' + opts.boostKey + ' by [' + boostName.textContent + ']('+ opts.boostAuthor + ')\n\n' + newContent
59+ textarea.value = content
60+ }
61+
62+ else if (opts.mentions) {
4963 var textarea = h('textarea.compose', opts.mentions)
5064 }
5165
5266 else if (opts.type == 'wiki')
render.jsView
@@ -237,8 +237,9 @@
237237
238238 var name = avatar.name(msg.value.author)
239239
240240 var buttons = h('div.buttons')
241+
241242 buttons.appendChild(h('button.btn', 'Reply', {
242243 onclick: function () {
243244 opts.type = 'post'
244245 opts.mentions = '[' + name.textContent + '](' + msg.value.author + ')'
@@ -255,8 +256,30 @@
255256 message.parentNode.insertBefore(compose, message.nextSibling)
256257 }
257258 }))
258259
260+ buttons.appendChild(h('button.btn', 'Boost', {
261+ onclick: function () {
262+ opts.type = 'post'
263+ opts.mentions = '[' + name.textContent + '](' + msg.value.author + ')'
264+ if (msg.value.content.recps) {
265+ opts.recps = msg.value.content.recps
266+ }
267+ var r = message.childNodes.length - 1
268+ delete opts.updated
269+ delete opts.original
270+ delete fallback.messageText
271+ opts.boostContent = msg.value.content.text
272+ opts.boostKey = msg.key
273+ opts.boostAuthor = msg.value.author
274+ fallback.buttons = message.childNodes[r]
275+ var compose = h('div.message#re:' + msg.key.substring(0, 44), composer(opts, fallback))
276+ message.removeChild(message.childNodes[r])
277+ message.parentNode.insertBefore(compose, message.nextSibling)
278+ }
279+ }))
280+
281+
259282 if (msg.value.author == id)
260283 buttons.appendChild(h('button.btn', 'Edit', {
261284 onclick: function () {
262285 opts.type = 'edit'

Built with git-ssb-web