git ssb

16+

Dominic / patchbay



Commit b6676bc5cff16aac24aefc3339ca7e655b7396c2

use hyperprogress

Dominic Tarr committed on 7/24/2016, 5:17:10 AM
Parent: 8cbcf91233c73cb8de180f682d84a828fdbde387

Files changed

modules/invite.jschanged
modules/invite.jsView
@@ -3,12 +3,15 @@
33 var ssbClient = require('ssb-client')
44 var id = require('../keys').id
55 var h = require('hyperscript')
66
7+var Progress = require('hyperprogress')
8+
79 var plugs = require('../plugs')
810 var sbot_publish = plugs.first(exports.sbot_publish = [])
911
1012
13+
1114 exports.screen_view = function (invite) {
1215
1316 //check that invite is
1417 // ws:...~shs:key:seed
@@ -20,16 +23,16 @@
2023 if(!/^(net|wss?)$/.test(parts[0][0])) return null
2124 if(parts[1][0] !== 'shs') return null
2225 if(parts[1].length !== 3) return null
2326
27+ var progress = Progress(4)
28+
2429 //connect to server
2530 //request follow
2631 //post pub announce
2732 //post follow pub
28- var progress = h('h1')
29- var status = h('pre')
3033 var div = h('div',
31- progress, status,
34+ progress,
3235 h('a', 'accept', {href: '#', onclick: function (ev) {
3336 ev.preventDefault()
3437 ev.stopPropagation()
3538 attempt()
@@ -37,33 +40,20 @@
3740 }})
3841 )
3942
4043 function attempt () {
41- progress.textContent = '*'
42- status.textContent = 'connecting...'
43-
44- console.log("CONNECT", invite)
44+ progress.next('connecting...')
4545 ssbClient(null, {
4646 remote: invite,
4747 manifest: { invite: {use: 'async'}, getAddress: 'async' }
4848 }, function (err, sbot) {
49- console.log("ERR?", err, sbot)
50- if(err) {
51- progress.textContent = '*!'
52- status.textContent = err.stack
53- return
54- }
55- progress.textContent = '**'
56- status.textContent = 'requesting follow...' + id
49+ if(err) return progress.fail(err)
50+ else progress.next('requesting follow...')
5751
5852 sbot.invite.use({feed: id}, function (err, msg) {
59- if(err) {
60- progress.textContent = '**!'
61- status.textContent = err.stack
62- return
63- }
64- progress.textContent = '***'
65- status.textContent = 'following...'
53+ if(err) return progres.fail(err)
54+
55+ progress.next('following...')
6656
6757 //remove the seed from the shs address.
6858 //then it's correct address.
6959 //this should make the browser connect to this as remote.
@@ -76,18 +66,12 @@
7666
7767 sbot_publish({
7868 type: 'contact',
7969 contact: sbot.id,
80- following: true
70+ following: true,
8171 }, function (err) {
82- if(err) {
83- progress.textContent = '***!'
84- status.textContent = err.stack
85- return
86- }
87- progress.textContent = '****'
88- status.textContent = 'READY!'
89-
72+ if(err) return progress.fail(err)
73+ progress.complete()
9074 })
9175
9276 })
9377 })

Built with git-ssb-web