git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 82667629e00c7d73e813e77adc04302f468562dc

Nextify mentions stream, add public/private messaging to profile pages

Ev Bogue committed on 6/11/2018, 9:28:38 PM
Parent: 84ba00f843d2ade9e33ea85b6ece83da282514c0

Files changed

views.jschanged
views.jsView
@@ -10,8 +10,9 @@
1010 var Next = require('pull-next-query')
1111
1212 var config = require('./config')()
1313
14+var tools = require('./tools')
1415 var avatar = require('./avatar')
1516 var id = require('./keys').id
1617
1718 var fs = require('fs')
@@ -27,61 +28,8 @@
2728
2829 screen.appendChild(hyperscroll(content))
2930 }
3031
31-var edit = function() {
32- var content = h('div.content')
33-
34- var screen = document.getElementById('screen')
35-
36- screen.appendChild(hyperscroll(content))
37-
38- var nameInput = h('input', {placeholder: 'New name'})
39-
40- var locInput = h('input', {placeholder: 'New location'})
41-
42- var descInput = h('textarea', {placeholder: 'New description'})
43-
44- var editor = h('div.message',
45- h('h1', 'Edit profile'),
46- nameInput,
47- h('button.btn.btn-primary', 'Preview', {onclick: function () {
48- if(nameInput.value) {
49- api.message_confirm({
50- type: 'about',
51- about: id,
52- name: nameInput.value || undefined
53- })
54- }
55- }}),
56- h('hr'),
57- locInput,
58- h('button.btn.btn-primary', 'Preview', {onclick: function () {
59- if(locInput.value) {
60- api.message_confirm({
61- type: 'loc',
62- about: id,
63- loc: locInput.value || undefined
64- })
65- }
66- }}),
67- h('hr'),
68- descInput,
69- h('button.btn.btn-primary', 'Preview', {onclick: function (){
70- if(descInput.value) {
71- api.message_confirm({
72- type: 'description',
73- about: id,
74- description: descInput.value || undefined
75- })
76- }
77- }}),
78- h('hr')
79- )
80-
81- content.appendChild(editor)
82-}
83-
8432 var mentionsStream = function () {
8533 var content = h('div.content')
8634
8735 var screen = document.getElementById('screen')
@@ -89,22 +37,34 @@
8937 screen.appendChild(hyperscroll(content))
9038
9139 function createStream (opts) {
9240 return pull(
93- sbot.backlinks({query: [{$filter: {dest: id}}], reverse: true}),
41+ Next(sbot.backlinks, opts, ['value', 'timestamp']),
9442 pull.map(function (msg) {
95- //if (msg.value.private == true)
96- // return 'ignoring private message'
97- //else
9843 return render(msg)
9944 })
10045 )
10146 }
10247
10348 pull(
104- createStream({reverse: true, limit: 10}),
49+ createStream({
50+ limit: 10,
51+ reverse: true,
52+ live: false,
53+ query: [{$filter: {dest: id}}]
54+ }),
10555 stream.bottom(content)
10656 )
57+
58+ pull(
59+ createStream({
60+ limit: 10,
61+ old: false,
62+ live: true,
63+ query: [{$filter: {dest: id}}]
64+ }),
65+ stream.top(content)
66+ )
10767 }
10868
10969 var userStream = function (src) {
11070 var content = h('div.content')
@@ -137,47 +97,48 @@
13797 } else {
13898 screen.firstChild.appendChild(profile)
13999 }
140100
101+ var name = avatar.name(src)
102+
141103 var avatars = h('div.avatars',
142104 h('a', {href: '#' + src},
143105 h('span.avatar--medium', avatar.image(src)),
144- avatar.name(src)
106+ name
145107 )
146108 )
147109
148110 var buttons = h('div.buttons')
149-
150111
151112 profile.firstChild.appendChild(avatars)
152113 profile.firstChild.appendChild(buttons)
114+ buttons.appendChild(tools.mute(src))
153115
154- if (!localStorage[src])
155- var cache = {mute: false}
156- else
157- var cache = JSON.parse(localStorage[src])
116+ console.log(name)
158117
159- console.log(cache)
118+ var writeMessage = h('button.btn', 'Public message ' + name.textContent, {
119+ onclick: function () {
120+ opts = {}
121+ opts.type = 'post'
122+ opts.mentions = '[' + name.textContent + '](' + src + ')'
123+ var composer = h('div#composer', h('div.message', compose(opts)))
124+ profile.appendChild(composer)
125+ }
126+ })
127+
128+ var writePrivate = h('button.btn', 'Private message ' + name.textContent, {
129+ onclick: function () {
130+ opts = {}
131+ opts.type = 'post'
132+ opts.mentions = '[' + name.textContent + '](' + src + ')'
133+ opts.recps = [src, id]
134+ var composer = h('div#composer', h('div.message', compose(opts)))
135+ profile.appendChild(composer)
136+ }
137+ })
160138
161- if (cache.mute == true)
162- var mute = h('button.btn', 'Unmute', {
163- onclick: function () {
164- cache.mute = false
165- localStorage[src] = JSON.stringify(cache)
166- location.reload()
167- }
168- })
169- else
170- var mute = h('button.btn', 'Mute', {
171- onclick: function () {
172- cache.mute = true
173- localStorage[src] = JSON.stringify(cache)
174- location.reload()
175- }
176- })
177-
178- buttons.appendChild(mute)
179-
139+ buttons.appendChild(writeMessage)
140+ buttons.appendChild(writePrivate)
180141 }
181142
182143 var msgThread = function (src) {
183144

Built with git-ssb-web