git ssb

16+

Dominic / patchbay



Commit 243dc738c8a3bb3083cc0b69bd8e4585c4b2e87c

Merge pull request #203 from ssbc/mutual_fix

ssb-mutual fix
mix irving authored on 7/5/2018, 1:02:00 AM
GitHub committed on 7/5/2018, 1:02:00 AM
Parent: f65e59e20db942a4f9f3250c67b8df054b0bafa9
Parent: 3890186af42330ec9d3fadeb3d60949153b60b0a

Files changed

about/html/edit.jschanged
background-process.jschanged
about/html/edit.jsView
@@ -2,15 +2,14 @@
22 const dataurl = require('dataurl-')
33 const hyperfile = require('hyperfile')
44 const hypercrop = require('hypercrop')
55 const hyperlightbox = require('hyperlightbox')
6-const Mutual = require('ssb-mutual')
7-
86 const {
9- h, Value, Dict: MutantObject, Struct,
10- map, computed, when, dictToCollection
7 + h, Value, Dict, Struct,
8 + map, computed, when, dictToCollection, onceTrue
119 } = require('mutant')
1210 const pull = require('pull-stream')
11 +const Mutual = require('ssb-mutual')
1312
1413 exports.gives = nest('about.html.edit')
1514
1615 exports.needs = nest({
@@ -38,13 +37,12 @@
3837
3938 // TODO refactor this to use obs better
4039 function edit (id) {
4140 // TODO - get this to wait till the connection is present !
42- var mutual = Mutual.init(api.sbot.obs.connection())
4341
4442 var avatar = Struct({
4543 current: api.about.obs.imageUrl(id),
46- new: MutantObject()
44 + new: Dict()
4745 })
4846
4947 const links = api.sbot.pull.links
5048
@@ -54,9 +52,9 @@
5452 })
5553
5654 const images = computed(api.about.obs.groupedValues(id, 'image'), Object.keys)
5755
58- var namesRecord = MutantObject()
56 + var namesRecord = Dict()
5957 // TODO constrain query to one name per peer?
6058 pull(
6159 links({dest: id, rel: 'about', values: true}),
6260 pull.map(e => e.value.content.name),
@@ -83,18 +81,17 @@
8381 if (name.new) return name.new
8482 else return name.current
8583 })
8684
87- var balances_div = h('div.balances')
85 + var balances = Dict()
86 + onceTrue(api.sbot.obs.connection, sbot => {
87 + if (!sbot.links) throw new Error('where ma sbot.links at?!')
88 + var mutual = Mutual.init(sbot)
89 + mutual.getAccountBalances(id, (err, data) => {
90 + if (err) console.log(err)
91 + if (data == null) return
8892
89- mutual.getAccountBalances(id, (error, balances) => {
90- if (balances == null) return ''
91-
92- var balance_els = []
93- Object.keys(balances).forEach(function (key) {
94- balances_div.appendChild(
95- h('div', `💰 ${balances[key]} ${key}`)
96- )
93 + balances.set(data)
9794 })
9895 })
9996
10097 return h('AboutEditor', [
@@ -108,9 +105,11 @@
108105 h('section.description', computed(api.about.obs.description(id), (descr) => {
109106 if (descr == null) return '' // TODO: should be in patchcore, I think...
110107 return api.message.html.markdown(descr)
111108 })),
112- h('section.credit', balances_div),
109 + h('section.credit', map(dictToCollection(balances), balance => {
110 + return h('div', ['💰 ', balance.value, ' ', balance.key])
111 + })),
113112 h('section.aliases', [
114113 h('header', 'Aliases'),
115114 h('section.avatars', [
116115 h('header', 'Avatars'),
background-process.jsView
@@ -12,17 +12,18 @@
1212 .use(require('scuttlebot/plugins/local'))
1313 .use(require('scuttlebot/plugins/logging'))
1414 .use(require('ssb-about'))
1515 .use(require('ssb-backlinks'))
16 + .use(require('ssb-blobs'))
17 + .use(require('ssb-chess-db'))
18 + .use(require('ssb-ebt'))
1619 .use(require('ssb-friends'))
20 + .use(require('ssb-meme'))
1721 .use(require('ssb-private'))
18- .use(require('ssb-blobs'))
22 + .use(require('ssb-query'))
1923 .use(require('ssb-search'))
20- .use(require('ssb-meme'))
21- .use(require('ssb-ebt'))
22- .use(require('ssb-chess-db'))
23- .use(require('ssb-query'))
2424 .use(require('ssb-ws'))
25 + // .use(require('ssb-mutual')) // this is has recursion problems atm
2526
2627 // pull config options out of depject
2728 var config = require('./config').create().config.sync.load()
2829

Built with git-ssb-web