git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 9ac76bea4f88cc5ca22ff5d5f4a4c06980dda5b8

fix spacing and recursive error when fetching thread messages

Ev Bogue committed on 2/13/2019, 5:50:50 AM
Parent: 73e7d576ed222947d6e6508457bf26c7868b1786

Files changed

views.jschanged
views.jsView
@@ -274,191 +274,193 @@
274274 }
275275
276276 var userStream = function (src) {
277277 var content = h('div.content')
278- var screen = document.getElementById('screen')
279- screen.appendChild(hyperscroll(content))
280- function createStream (opts) {
281- return pull(
282- More(sbot.userStream, opts, ['value', 'sequence']),
283- pull.map(function (msg) {
284- return render(h('div', msg))
285- })
286- )
287- }
278+ var screen = document.getElementById('screen')
288279
289- pull(
290- createStream({old: false, limit: 10, id: src}),
291- stream.top(content)
292- )
280+ screen.appendChild(hyperscroll(content))
293281
294- pull(
295- createStream({reverse: true, live: false, limit: 10, id: src}),
296- stream.bottom(content)
282+ function createStream (opts) {
283+ return pull(
284+ More(sbot.userStream, opts, ['value', 'sequence']),
285+ pull.map(function (msg) {
286+ return render(h('div', msg))
287+ })
297288 )
289+ }
298290
299- var profile = h('div.content#profile', h('div.message'))
291+ pull(
292+ createStream({old: false, limit: 10, id: src}),
293+ stream.top(content)
294+ )
300295
301- if (screen.firstChild.firstChild) {
302- screen.firstChild.insertBefore(profile, screen.firstChild.firstChild)
303- } else {
304- screen.firstChild.appendChild(profile)
305- }
296+ pull(
297+ createStream({reverse: true, live: false, limit: 10, id: src}),
298+ stream.bottom(content)
299+ )
306300
307- var name = avatar.name(src)
301+ var profile = h('div.content#profile', h('div.message'))
308302
309- var editname = h('span',
310- avatar.name(src),
311- h('button.btn', 'New name', {
312- onclick: function () {
313- var nameput = h('input', {placeholder: name.textContent})
314- var nameedit =
315- h('span', nameput,
316- h('button.btn', 'Preview', {
317- onclick: function () {
318- if (nameput.value[0] != '@')
319- tobename = nameput.value
320- else
321- tobename = nameput.value.substring(1, 100)
322- var newname = h('span', h('a', {href: '#' + src}, '@' + tobename), h('button.btn', 'Publish', {
323- onclick: function () {
324- var donename = h('span', h('a', {href: '#' + src}, '@' + tobename))
325- sbot.publish({type: 'about', about: src, name: tobename})
326- localStorage[src + 'name'] = tobename
327- newname.parentNode.replaceChild(donename, newname)
328- }
329- }))
330- nameedit.parentNode.replaceChild(newname, nameedit)
331- }
332- })
333- )
334- editname.parentNode.replaceChild(nameedit, editname)
335- }
336- })
337- )
303+ if (screen.firstChild.firstChild) {
304+ screen.firstChild.insertBefore(profile, screen.firstChild.firstChild)
305+ } else {
306+ screen.firstChild.appendChild(profile)
307+ }
338308
339- var editimage = h('span',
340- h('button.btn', 'New image', {
341- onclick: function () {
342- var upload =
343- h('span',
344- hyperfile.asDataURL(function (data) {
345- if(data) {
346- //img.src = data
347- var _data = dataurl.parse(data)
348- pull(
349- pull.once(_data.data),
350- sbot.addblob(function (err, hash) {
351- if(err) return alert(err.stack)
352- selected = {
353- link: hash,
354- size: _data.data.length,
355- type: _data.mimetype
356- }
357- })
358- )
309+ var name = avatar.name(src)
310+
311+ var editname = h('span',
312+ avatar.name(src),
313+ h('button.btn', 'New name', {
314+ onclick: function () {
315+ var nameput = h('input', {placeholder: name.textContent})
316+ var nameedit =
317+ h('span', nameput,
318+ h('button.btn', 'Preview', {
319+ onclick: function () {
320+ if (nameput.value[0] != '@')
321+ tobename = nameput.value
322+ else
323+ tobename = nameput.value.substring(1, 100)
324+ var newname = h('span', h('a', {href: '#' + src}, '@' + tobename), h('button.btn', 'Publish', {
325+ onclick: function () {
326+ var donename = h('span', h('a', {href: '#' + src}, '@' + tobename))
327+ sbot.publish({type: 'about', about: src, name: tobename})
328+ localStorage[src + 'name'] = tobename
329+ newname.parentNode.replaceChild(donename, newname)
330+ }
331+ }))
332+ nameedit.parentNode.replaceChild(newname, nameedit)
359333 }
360- }),
361- h('button.btn', 'Preview image', {
362- onclick: function() {
363- if (selected) {
364- console.log(selected)
365- var oldImage = document.getElementById('profileImage')
366- var newImage = h('span.avatar--medium', h('img', {src: config.blobsUrl + selected.link}))
367- var publish = h('button.btn', 'Publish image', {
368- onclick: function () {
369- sbot.publish({
370- type: 'about',
371- about: src,
372- image: selected
373- }, function (err, published) {
374- console.log(published)
375- })
376- }
377- })
378- upload.parentNode.replaceChild(publish, upload)
379- oldImage.parentNode.replaceChild(newImage, oldImage)
380- }
381- /*if(selected) {
382- api.message_confirm({
383- type: 'about',
384- about: id,
385- image: selected
386- })
387- } else { alert('select an image before hitting preview')}*/
388- }
389334 })
390335 )
391- editimage.parentNode.replaceChild(upload, editimage)
392- }
393- })
394- )
336+ editname.parentNode.replaceChild(nameedit, editname)
337+ }
338+ })
339+ )
395340
396- var avatars = h('div.avatars',
397- h('a', {href: '#' + src},
398- h('span.avatar--medium#profileImage', avatar.image(src)),
399- editname,
400- h('br'),
401- editimage
402- )
341+ var editimage = h('span',
342+ h('button.btn', 'New image', {
343+ onclick: function () {
344+ var upload =
345+ h('span',
346+ hyperfile.asDataURL(function (data) {
347+ if(data) {
348+ //img.src = data
349+ var _data = dataurl.parse(data)
350+ pull(
351+ pull.once(_data.data),
352+ sbot.addblob(function (err, hash) {
353+ if(err) return alert(err.stack)
354+ selected = {
355+ link: hash,
356+ size: _data.data.length,
357+ type: _data.mimetype
358+ }
359+ })
360+ )
361+ }
362+ }),
363+ h('button.btn', 'Preview image', {
364+ onclick: function() {
365+ if (selected) {
366+ console.log(selected)
367+ var oldImage = document.getElementById('profileImage')
368+ var newImage = h('span.avatar--medium', h('img', {src: config.blobsUrl + selected.link}))
369+ var publish = h('button.btn', 'Publish image', {
370+ onclick: function () {
371+ sbot.publish({
372+ type: 'about',
373+ about: src,
374+ image: selected
375+ }, function (err, published) {
376+ console.log(published)
377+ })
378+ }
379+ })
380+ upload.parentNode.replaceChild(publish, upload)
381+ oldImage.parentNode.replaceChild(newImage, oldImage)
382+ }
383+ /*if(selected) {
384+ api.message_confirm({
385+ type: 'about',
386+ about: id,
387+ image: selected
388+ })
389+ } else { alert('select an image before hitting preview')}*/
390+ }
391+ })
392+ )
393+ editimage.parentNode.replaceChild(upload, editimage)
394+ }
395+ })
396+ )
397+
398+ var avatars = h('div.avatars',
399+ h('a', {href: '#' + src},
400+ h('span.avatar--medium#profileImage', avatar.image(src)),
401+ editname,
402+ h('br'),
403+ editimage
403404 )
404-
405- pull(
406- sbot.userStream({id: src, reverse: false, limit: 1}),
407- pull.drain(function (msg) {
408- var howlong = h('span', h('br'), ' arrived ', human(new Date(msg.value.timestamp)))
409- avatars.appendChild(howlong)
410- console.log(msg)
411- })
412- )
405+ )
406+
407+ pull(
408+ sbot.userStream({id: src, reverse: false, limit: 1}),
409+ pull.drain(function (msg) {
410+ var howlong = h('span', h('br'), ' arrived ', human(new Date(msg.value.timestamp)))
411+ avatars.appendChild(howlong)
412+ console.log(msg)
413+ })
414+ )
413415
414416
415- var buttons = h('div.buttons')
416-
417- profile.firstChild.appendChild(avatars)
418- profile.firstChild.appendChild(buttons)
419- buttons.appendChild(tools.mute(src))
417+ var buttons = h('div.buttons')
418+
419+ profile.firstChild.appendChild(avatars)
420+ profile.firstChild.appendChild(buttons)
421+ buttons.appendChild(tools.mute(src))
420422
421- var writeMessage = h('button.btn', 'Public message ', avatar.name(src), {
422- onclick: function () {
423- opts = {}
424- opts.type = 'post'
425- opts.mentions = '[' + name.textContent + '](' + src + ')'
426- var composer = h('div#composer', h('div.message', compose(opts)))
427- profile.appendChild(composer)
428- }
429- })
423+ var writeMessage = h('button.btn', 'Public message ', avatar.name(src), {
424+ onclick: function () {
425+ opts = {}
426+ opts.type = 'post'
427+ opts.mentions = '[' + name.textContent + '](' + src + ')'
428+ var composer = h('div#composer', h('div.message', compose(opts)))
429+ profile.appendChild(composer)
430+ }
431+ })
430432
431- var writePrivate = h('button.btn', 'Private message ', avatar.name(src), {
432- onclick: function () {
433- opts = {}
434- opts.type = 'post'
435- opts.mentions = '[' + name.textContent + '](' + src + ')'
436- opts.recps = [src, id]
437- var composer = h('div#composer', h('div.message', compose(opts)))
438- profile.appendChild(composer)
439- }
440- })
433+ var writePrivate = h('button.btn', 'Private message ', avatar.name(src), {
434+ onclick: function () {
435+ opts = {}
436+ opts.type = 'post'
437+ opts.mentions = '[' + name.textContent + '](' + src + ')'
438+ opts.recps = [src, id]
439+ var composer = h('div#composer', h('div.message', compose(opts)))
440+ profile.appendChild(composer)
441+ }
442+ })
441443
442- buttons.appendChild(writeMessage)
443- buttons.appendChild(writePrivate)
444- buttons.appendChild(tools.follow(src))
445- buttons.appendChild(tools.block(src))
444+ buttons.appendChild(writeMessage)
445+ buttons.appendChild(writePrivate)
446+ buttons.appendChild(tools.follow(src))
447+ buttons.appendChild(tools.block(src))
446448
447- buttons.appendChild(h('button.btn', 'Generate follows', {
448- onclick: function () {
449- profile.firstChild.appendChild(tools.getFollowing(src))
450- profile.firstChild.appendChild(tools.getFollowers(src))
451- }
452- }))
449+ buttons.appendChild(h('button.btn', 'Generate follows', {
450+ onclick: function () {
451+ profile.firstChild.appendChild(tools.getFollowing(src))
452+ profile.firstChild.appendChild(tools.getFollowers(src))
453+ }
454+ }))
453455
454- buttons.appendChild(h('button.btn', 'Generate blocks', {
455- onclick: function () {
456- profile.firstChild.appendChild(tools.getBlocks(src))
457- profile.firstChild.appendChild(tools.getBlocked(src))
458- }
459- }))
460- buttons.appendChild(h('a', {href: '#wall/' + src}, h('button.btn', avatar.name(src), "'s wall")))
456+ buttons.appendChild(h('button.btn', 'Generate blocks', {
457+ onclick: function () {
458+ profile.firstChild.appendChild(tools.getBlocks(src))
459+ profile.firstChild.appendChild(tools.getBlocked(src))
460+ }
461+ }))
462+ buttons.appendChild(h('a', {href: '#wall/' + src}, h('button.btn', avatar.name(src), "'s wall")))
461463
462464 }
463465
464466 var privateMsg = function (src) {
@@ -496,26 +498,26 @@
496498 }
497499 })
498500 )
499501
500-
501502 sbot.get(src, function (err, data) {
502503 if (err) {
503504 var message = h('div.message', 'Missing message!')
504505 content.appendChild(message)
505506 }
506507 if (data) {
507- data.value = data
508- data.key = src
509- console.log(data)
510- var rootMsg = render(data)
508+ var message = {}
509+ message.value = data
510+ message.key = src
511+ console.log(message)
512+ var rootMsg = render(message)
511513
512514 if (content.firstChild) {
513515 content.insertBefore(rootMsg, content.firstChild)
514516 } else {
515517 content.appendChild(rootMsg)
516518 }
517- if (data.value.content.type == 'git-repo') {
519+ if (message.value.content.type == 'git-repo') {
518520 pull(
519521 sbot.backlinks({query: [{$filter: {value: {content: {type: 'git-update'}}, dest: src}}]}),
520522 pull.drain(function (msg) {
521523 if (msg.value) {
@@ -526,8 +528,9 @@
526528 }
527529
528530 }
529531 })
532+
530533 }
531534
532535 var keyPage = function () {
533536 var screen = document.getElementById('screen')
@@ -765,8 +768,8 @@
765768 else
766769 search(src.substr(1).split('%20').join(' '))
767770 } else {
768771 everythingStream()
769- checkInvite()
772+ //checkInvite()
770773 }
771774
772775 }

Built with git-ssb-web