git ssb

2+

ev / mvd



Commit 84ba00f843d2ade9e33ea85b6ece83da282514c0

handle private messages, and public mentions within compose

Ev Bogue committed on 6/11/2018, 9:28:12 PM
Parent: e63daf47ce2227a1684f6560aae950ed93881725

Files changed

compose.jschanged
compose.jsView
@@ -2,8 +2,9 @@
22 var pull = require('pull-stream')
33 var sbot = require('./scuttlebot')
44 var human = require('human-time')
55 var id = require('./keys').id
6 +var mentions = require('ssb-mentions')
67
78 var tools = require('./tools')
89
910 var mime = require('simple-mime')('application/octect-stream')
@@ -43,17 +44,22 @@
4344
4445 var composer = h('div.composer')
4546 var container = h('div.container')
4647
47- if (opts.type == 'post')
48 + if (opts.mentions) {
49 + var textarea = h('textarea.compose', opts.mentions)
50 + }
51 +
52 + else if (opts.type == 'post')
4853 var textarea = h('textarea.compose', {placeholder: opts.placeholder || 'Write a message'})
4954 else
5055 var textarea = h('textarea.compose', {placeholder: opts.placeholder || 'Write a message'}, fallback.messageText)
5156
5257 var cancelBtn = h('button.btn', 'Cancel', {
5358 onclick: function () {
5459 var cancel
5560 console.log(opts)
61 +
5662 if (opts.type == 'edit') {
5763 cancel = document.getElementById('edit:' + opts.branch.substring(0,44))
5864 var oldMessage = h('div.message__body', tools.markdown(fallback.messageText))
5965 cancel.parentNode.replaceChild(oldMessage, cancel)
@@ -82,10 +88,24 @@
8288 msg.value = {
8389 "author": id,
8490 "content": opts
8591 }
86-
92 +
8793 msg.value.content.text = textarea.value
94 + msg.value.content.mentions = mentions(textarea.value).map(
95 + function (mention) {
96 + var file = filesById[mention.link]
97 + if (file) {
98 + if (file.type) mention.type = file.type
99 + if (file.size) mention.size = file.size
100 + }
101 + return mention
102 + }
103 + )
104 +
105 + if (opts.recps)
106 + msg.value.private = true
107 +
88108 console.log(msg)
89109 if (opts.type == 'post')
90110 var header = tools.header(msg)
91111 if (opts.type == 'update')

Built with git-ssb-web