git ssb

16+

Dominic / patchbay



Commit 42a6e511880c97c5b0b5d8ba131f7173b493ede4

Merge pull request #191 from ssbc/quote-example

Add quote button
Anders Rune Jensen authored on 4/25/2018, 12:37:44 PM
GitHub committed on 4/25/2018, 12:37:44 PM
Parent: 822a744863931f6f173393bae8f44e31debafb99
Parent: c0a883625eb62b7bdc71dd9ef7b1fdac62f4278b

Files changed

main.jschanged
message/html/compose.jschanged
post-patchcore/message/html/action/quote.jsadded
main.jsView
@@ -26,8 +26,14 @@
2626 history: require('patch-history')
2727 }
2828 }
2929
30 +const post = {
31 + patchbay: {
32 + message: bulk(__dirname, [ 'post-patchcore/message/**/*.js' ])
33 + }
34 +}
35 +
3036 // from more specialized to more general
3137 const sockets = combine(
3238 // require('ssb-horcrux'),
3339 // require('patch-hub'),
@@ -36,9 +42,10 @@
3642 require('patchbay-gatherings'),
3743 require('patchbay-book'),
3844 // require('patch-network),
3945 patchbay,
40- require('patchcore')
46 + require('patchcore'),
47 + post
4148 )
4249
4350 const api = entry(sockets, nest('app.html.app', 'first'))
4451 const app = api.app.html.app
message/html/compose.jsView
@@ -148,8 +148,23 @@
148148 warning,
149149 actions
150150 ])
151151
152 + composer.addQuote = function (data) {
153 + try {
154 + if (typeof data.content.text === 'string') {
155 + var text = data.content.text
156 + textArea.value += '> ' + text.replace(/\r\n|\r|\n/g,'\n> ') + '\r\n\n'
157 + hasContent.set(!!textArea.value)
158 + }
159 + } catch(err) {
160 + // object not have text or content
161 + }
162 + }
163 +
164 + if (location.action == 'quote')
165 + composer.addQuote(location.value)
166 +
152167 addSuggest(channelInput, (inputText, cb) => {
153168 if (inputText[0] === '#') {
154169 cb(null, getChannelSuggestions(inputText.slice(1)))
155170 }
post-patchcore/message/html/action/quote.jsView
@@ -1,0 +1,17 @@
1 +var h = require('mutant/h')
2 +var nest = require('depnest')
3 +
4 +exports.needs = nest({
5 + 'app.sync.goTo': 'first'
6 +})
7 +
8 +exports.gives = nest('message.html.action')
9 +
10 +exports.create = (api) => {
11 + return nest('message.html.action', function quote (msg) {
12 + return h('a', {
13 + href: '#',
14 + 'ev-click': () => api.app.sync.goTo({ action: 'quote', key: msg.key, value: msg.value })
15 + }, 'Quote')
16 + })
17 +}

Built with git-ssb-web