git ssb

0+

dangerousbeans / yap



forked from Dominic / yap

Commit 005856970f52098bfb3fd216a0c32b83d7b0cfe8

update preview and mentions

Dominic Tarr committed on 2/9/2019, 6:33:26 AM
Parent: 9aa745d5b64d523212242af3c2c8b7a5f69227ea

Files changed

apis/mentions.jschanged
apis/preview.jschanged
apis/mentions.jsView
@@ -1,50 +1,50 @@
11 var u = require('../util')
22 var explain = require('explain-error')
33 var getMentions = require('../mentions')
44
5-module.exports = function (opts) {
6- var self = this
7- var api = this.api
8- return function (cb) {
9- getMentions(self.sbot, opts.text, function (err, mentions, ambigious) {
10- if(err) return cb(explain(err, 'could not load mentions'))
11- function toPath () {
12- return '['+[].join.call(arguments, '][')+']'
13- }
14- mentions
15- if(ambigious.length)
16- ambigious.forEach(function (e) {
17- mentions.push({name: e[0].name, link: e[0].id})
18- })
5+module.exports = function (sbot) {
6+ return function (opts, apply) {
7+ return function (cb) {
8+ getMentions(sbot, opts.text, function (err, mentions, ambigious) {
9+ if(err) return cb(explain(err, 'could not load mentions'))
10+ function toPath () {
11+ return '['+[].join.call(arguments, '][')+']'
12+ }
13+ mentions
14+ if(ambigious.length)
15+ ambigious.forEach(function (e) {
16+ mentions.push({name: e[0].name, link: e[0].id})
17+ })
1918
20- function toPath () {
21- return '['+[].join.call(arguments, '][')+']'
22- }
19+ function toPath () {
20+ return '['+[].join.call(arguments, '][')+']'
21+ }
2322
2423
25- cb(null, [
26- mentions.map(function (opts) { return api(['avatar'], opts) }),
27- u.createHiddenInputs({mentions: mentions}, 'content'),
28- ambigious.map(function (e, i) {
29- return [
30- 'div.AmbigiousMentions',
31- e[0].name,
32- ['input', {
33- type: 'hidden',
34- name: toPath('content', 'mentions', mentions.length + i),
35- value: e[0].name
36- }],
37- ['select', {
38- name: toPath('content', 'mentions', mentions.length + i),
39- },
40- e.map(function (e, i) {
41- return ['option', !i ? {selected: true, value: e.id} : {value: e.id}, e.id.substring(0, 12)+'...']
42- })
24+ cb(null, [
25+ mentions.map(function (opts) { return apply('avatar', opts) }),
26+ u.createHiddenInputs({mentions: mentions}, 'content'),
27+ ambigious.map(function (e, i) {
28+ return [
29+ 'div.AmbigiousMentions',
30+ e[0].name,
31+ ['input', {
32+ type: 'hidden',
33+ name: toPath('content', 'mentions', mentions.length + i),
34+ value: e[0].name
35+ }],
36+ ['select', {
37+ name: toPath('content', 'mentions', mentions.length + i),
38+ },
39+ e.map(function (e, i) {
40+ return ['option', !i ? {selected: true, value: e.id} : {value: e.id}, e.id.substring(0, 12)+'...']
41+ })
42+ ]
4343 ]
44- ]
45- })
46- ])
47- })
44+ })
45+ ])
46+ })
47+ }
4848 }
4949 }
5050
apis/preview.jsView
@@ -11,17 +11,18 @@
1111 return function (opts, apply) {
1212 var id = opts.id
1313 var content = opts.content
1414
15+ console.error("preview", opts)
16+
1517 //fake message, with enough fields to give to message renderer
1618 var data = {
1719 key: '%................',
1820 value: {
1921 author: id,
2022 content: content
2123 }
2224 }
23- console.log("OPTS", opts)
2425 return ['div.MessagePreview',
2526 ['form',
2627 {name: 'publish', method: 'POST'},
2728 //TODO: enable changing the identity to publish as here
@@ -47,4 +48,5 @@
4748 //press back to edit body of the message again...
4849 //submit takes you to back to the thread page.
4950 }
5051 }
52+

Built with git-ssb-web