Commit 84ba00f843d2ade9e33ea85b6ece83da282514c0
handle private messages, and public mentions within compose
Ev Bogue committed on 6/11/2018, 9:28:12 PMParent: e63daf47ce2227a1684f6560aae950ed93881725
Files changed
compose.js | changed |
compose.js | ||
---|---|---|
@@ -2,8 +2,9 @@ | ||
2 | 2 | var pull = require('pull-stream') |
3 | 3 | var sbot = require('./scuttlebot') |
4 | 4 | var human = require('human-time') |
5 | 5 | var id = require('./keys').id |
6 | +var mentions = require('ssb-mentions') | |
6 | 7 | |
7 | 8 | var tools = require('./tools') |
8 | 9 | |
9 | 10 | var mime = require('simple-mime')('application/octect-stream') |
@@ -43,17 +44,22 @@ | ||
43 | 44 | |
44 | 45 | var composer = h('div.composer') |
45 | 46 | var container = h('div.container') |
46 | 47 | |
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') | |
48 | 53 | var textarea = h('textarea.compose', {placeholder: opts.placeholder || 'Write a message'}) |
49 | 54 | else |
50 | 55 | var textarea = h('textarea.compose', {placeholder: opts.placeholder || 'Write a message'}, fallback.messageText) |
51 | 56 | |
52 | 57 | var cancelBtn = h('button.btn', 'Cancel', { |
53 | 58 | onclick: function () { |
54 | 59 | var cancel |
55 | 60 | console.log(opts) |
61 | + | |
56 | 62 | if (opts.type == 'edit') { |
57 | 63 | cancel = document.getElementById('edit:' + opts.branch.substring(0,44)) |
58 | 64 | var oldMessage = h('div.message__body', tools.markdown(fallback.messageText)) |
59 | 65 | cancel.parentNode.replaceChild(oldMessage, cancel) |
@@ -82,10 +88,24 @@ | ||
82 | 88 | msg.value = { |
83 | 89 | "author": id, |
84 | 90 | "content": opts |
85 | 91 | } |
86 | - | |
92 | + | |
87 | 93 | 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 | + | |
88 | 108 | console.log(msg) |
89 | 109 | if (opts.type == 'post') |
90 | 110 | var header = tools.header(msg) |
91 | 111 | if (opts.type == 'update') |
Built with git-ssb-web