git ssb

2+

ev / mvd



Commit 9c6fb452a138c1a841302b2164284b0787c7bc3a

use chronological feed and clean up

Ev Bogue committed on 6/8/2018, 7:42:04 PM
Parent: 775cd1f02ae21d22846b32f6c1087ec13d735e8d

Files changed

index.jschanged
package-lock.jsonchanged
package.jsonchanged
render.jschanged
views.jschanged
index.jsView
@@ -29,11 +29,10 @@
2929 }
3030 }
3131 }
3232 })),
33- h('li', h('a', {href: '#' }, 'Queue')),
34- h('li', h('a', {href: '#posts' }, 'Posts')),
35- h('li', h('a', {href: '#all'}, 'All')),
33 + h('li', h('a', {href: '#' }, 'All')),
34 + h('li', h('a', {href: '#queue'}, 'Queue')),
3635 h('li', h('a', {href: '#key' }, 'Key')),
3736 h('li.right', h('a', {href: '#about'}, '?'))
3837 )
3938 )
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 218007 bytes
New file size: 218431 bytes
package.jsonView
@@ -22,8 +22,9 @@
2222 "human-time": "0.0.1",
2323 "hyperloadmore": "^1.1.0",
2424 "hyperscript": "^2.0.2",
2525 "hyperscroll": "^1.0.0",
26 + "mfr-query-stream": "^2.0.1",
2627 "muxrpcli": "^1.1.0",
2728 "non-private-ip": "^1.4.3",
2829 "opn": "^5.3.0",
2930 "os-homedir": "^1.0.2",
render.jsView
@@ -12,9 +12,14 @@
1212
1313 module.exports = function (msg) {
1414 var message = h('div.message#' + msg.key.substring(0, 44))
1515
16- if (localStorage['mute:' + msg.value.author]) {
16 + if (!localStorage[msg.value.author])
17 + var cache = {mute: false}
18 + else
19 + var cache = JSON.parse(localStorage[msg.value.author])
20 +
21 + if (cache.mute == true) {
1722 var muted = h('span', ' muted')
1823 message.appendChild(tools.mini(msg, muted))
1924 return message
2025 }
@@ -98,10 +103,10 @@
98103 }
99104 }))
100105
101106
102- var done = h('button.btn.right', '-')
103- var add = h('button.btn.right', '+')
107 + var done = h('button.btn.right', '+')
108 + var add = h('button.btn.right', '-')
104109
105110 buttons.appendChild(done)
106111 buttons.appendChild(add)
107112 buttons.appendChild(tools.star(msg))
views.jsView
@@ -78,32 +78,8 @@
7878
7979 content.appendChild(editor)
8080 }
8181
82-var queryStream = function () {
83- var content = h('div.content')
84-
85- var screen = document.getElementById('screen')
86-
87- screen.appendChild(hyperscroll(content))
88-
89- function createStream (opts) {
90- return pull(
91- //sbot.backlinks({query: [{$filter: { dest: id }}], reverse: true}),
92- sbot.query({query: [{$filter: { value: {content: {type: 'post'}, timestamp: { $gt: 1 }}}}], reverse: true}),
93- //sbot.query({query: [{$filter: { value: { content: {type: 'post'}, timestamp: { $gt: 0, $lt: undefined }}}}], reverse: true}),
94- pull.map(function (msg) {
95- return render(msg)
96- })
97- )
98- }
99-
100- pull(
101- createStream({reverse: true, limit: 10}),
102- stream.bottom(content)
103- )
104-}
105-
10682 var mentionsStream = function () {
10783 var content = h('div.content')
10884
10985 var screen = document.getElementById('screen')
@@ -127,34 +103,8 @@
127103 stream.bottom(content)
128104 )
129105 }
130106
131-var logStream = function () {
132- var content = h('div.content')
133- var screen = document.getElementById('screen')
134- screen.appendChild(hyperscroll(content))
135-
136- function createStream (opts) {
137- return pull(
138- More(sbot.createLogStream, opts),
139- pull.map(function (msg) {
140- return render(msg)
141- })
142-
143- )
144- }
145-
146- pull(
147- createStream({old: false, limit: 10}),
148- stream.top(content)
149- )
150-
151- pull(
152- createStream({reverse: true, live: false, limit: 10}),
153- stream.bottom(content)
154- )
155-}
156-
157107 var userStream = function (src) {
158108 var content = h('div.content')
159109 var screen = document.getElementById('screen')
160110 screen.appendChild(hyperscroll(content))
@@ -254,44 +204,10 @@
254204 content.appendChild(rootMsg)
255205 }
256206 })
257207
258- /*pull(
259- sbot.backlinks({query: [{$filter: {dest: src}}]}),
260- pull.drain(function (msg) {
261- console.log(msg)
262- content.appendChild(render(msg))
263- })
264- )*/
265-
266208 }
267209
268-/*var msgThread = function(src) {
269- var content = h('div.content')
270- var screen = document.getElementById('screen')
271- screen.appendChild(hyperscroll(content))
272- sbot.get(src, function (err, data) {
273- if (err) {console.log('could not find message') }
274- data.value = data
275- var root = src
276- if (data.value.content.root)
277- root = data.value.content.root
278- sbot.get(root, function (err, data) {
279- if (err) { console.log('could not find root')}
280- data.value = data
281- data.key = root
282- content.appendChild(render(data))
283- pull(
284- sbot.links({rel: 'root', dest: root, values: true, keys: true, live: true}),
285- pull.drain(function (msg) {
286- if (msg.value)
287- content.appendChild(render(msg))
288- })
289- )
290- })
291- })
292-}*/
293-
294210 var keyPage = function () {
295211 var screen = document.getElementById('screen')
296212
297213 var importKey = h('textarea.import', {placeholder: 'Import a new public/private key', name: 'textarea', style: 'width: 97%; height: 100px;'})
@@ -326,9 +242,44 @@
326242
327243 screen.appendChild(hyperscroll(content))
328244 }
329245
246 +function everythingStream () {
247 + var content = h('div.content')
330248
249 + var screen = document.getElementById('screen')
250 +
251 + screen.appendChild(hyperscroll(content))
252 +
253 + function newStream () {
254 + return pull(
255 + sbot.query({query: [{$filter: { value: { timestamp: { $gt: 0 }}}}], old: false, live: true}),
256 + pull.map(function (msg) {
257 + return render(msg)
258 + })
259 + )
260 + }
261 +
262 + function oldStream () {
263 + return pull(
264 + sbot.query({query: [{$filter: { value: { timestamp: { $gt: 0 }}}}], reverse: true, live: false}),
265 + pull.map(function (msg) {
266 + return render(msg)
267 + })
268 + )
269 + }
270 +
271 + pull(
272 + oldStream(),
273 + stream.bottom(content)
274 + )
275 +
276 + pull(
277 + newStream(),
278 + stream.top(content)
279 + )
280 +}
281 +
331282 function hash () {
332283 return window.location.hash.substring(1)
333284 }
334285
@@ -338,18 +289,16 @@
338289 if (ref.isFeed(src)) {
339290 userStream(src)
340291 } else if (ref.isMsg(src)) {
341292 msgThread(src)
342- } else if (src == 'all') {
343- logStream()
344- } else if (src == 'posts'){
345- queryStream()
293 + } else if (src == 'queue') {
294 + mentionsStream()
346295 } else if (src == 'about') {
347296 about()
348297 } else if (src == 'edit') {
349298 edit()
350299 } else if (src == 'key') {
351300 keyPage()
352301 } else {
353- mentionsStream()
302 + everythingStream()
354303 }
355304 }

Built with git-ssb-web