Commit 82667629e00c7d73e813e77adc04302f468562dc
Nextify mentions stream, add public/private messaging to profile pages
Ev Bogue committed on 6/11/2018, 9:28:38 PMParent: 84ba00f843d2ade9e33ea85b6ece83da282514c0
Files changed
views.js | changed |
views.js | ||
---|---|---|
@@ -10,8 +10,9 @@ | ||
10 | 10 … | var Next = require('pull-next-query') |
11 | 11 … | |
12 | 12 … | var config = require('./config')() |
13 | 13 … | |
14 … | +var tools = require('./tools') | |
14 | 15 … | var avatar = require('./avatar') |
15 | 16 … | var id = require('./keys').id |
16 | 17 … | |
17 | 18 … | var fs = require('fs') |
@@ -27,61 +28,8 @@ | ||
27 | 28 … | |
28 | 29 … | screen.appendChild(hyperscroll(content)) |
29 | 30 … | } |
30 | 31 … | |
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 | - | |
84 | 32 … | var mentionsStream = function () { |
85 | 33 … | var content = h('div.content') |
86 | 34 … | |
87 | 35 … | var screen = document.getElementById('screen') |
@@ -89,22 +37,34 @@ | ||
89 | 37 … | screen.appendChild(hyperscroll(content)) |
90 | 38 … | |
91 | 39 … | function createStream (opts) { |
92 | 40 … | return pull( |
93 | - sbot.backlinks({query: [{$filter: {dest: id}}], reverse: true}), | |
41 … | + Next(sbot.backlinks, opts, ['value', 'timestamp']), | |
94 | 42 … | pull.map(function (msg) { |
95 | - //if (msg.value.private == true) | |
96 | - // return 'ignoring private message' | |
97 | - //else | |
98 | 43 … | return render(msg) |
99 | 44 … | }) |
100 | 45 … | ) |
101 | 46 … | } |
102 | 47 … | |
103 | 48 … | pull( |
104 | - createStream({reverse: true, limit: 10}), | |
49 … | + createStream({ | |
50 … | + limit: 10, | |
51 … | + reverse: true, | |
52 … | + live: false, | |
53 … | + query: [{$filter: {dest: id}}] | |
54 … | + }), | |
105 | 55 … | stream.bottom(content) |
106 | 56 … | ) |
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 … | + ) | |
107 | 67 … | } |
108 | 68 … | |
109 | 69 … | var userStream = function (src) { |
110 | 70 … | var content = h('div.content') |
@@ -137,47 +97,48 @@ | ||
137 | 97 … | } else { |
138 | 98 … | screen.firstChild.appendChild(profile) |
139 | 99 … | } |
140 | 100 … | |
101 … | + var name = avatar.name(src) | |
102 … | + | |
141 | 103 … | var avatars = h('div.avatars', |
142 | 104 … | h('a', {href: '#' + src}, |
143 | 105 … | h('span.avatar--medium', avatar.image(src)), |
144 | - avatar.name(src) | |
106 … | + name | |
145 | 107 … | ) |
146 | 108 … | ) |
147 | 109 … | |
148 | 110 … | var buttons = h('div.buttons') |
149 | - | |
150 | 111 … | |
151 | 112 … | profile.firstChild.appendChild(avatars) |
152 | 113 … | profile.firstChild.appendChild(buttons) |
114 … | + buttons.appendChild(tools.mute(src)) | |
153 | 115 … | |
154 | - if (!localStorage[src]) | |
155 | - var cache = {mute: false} | |
156 | - else | |
157 | - var cache = JSON.parse(localStorage[src]) | |
116 … | + console.log(name) | |
158 | 117 … | |
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 … | + }) | |
160 | 138 … | |
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) | |
180 | 141 … | } |
181 | 142 … | |
182 | 143 … | var msgThread = function (src) { |
183 | 144 … |
Built with git-ssb-web