Commit 243dc738c8a3bb3083cc0b69bd8e4585c4b2e87c
Merge pull request #203 from ssbc/mutual_fix
ssb-mutual fixmix 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.js | changed |
background-process.js | changed |
about/html/edit.js | |||
---|---|---|---|
@@ -2,15 +2,14 @@ | |||
2 | 2 … | const dataurl = require('dataurl-') | |
3 | 3 … | const hyperfile = require('hyperfile') | |
4 | 4 … | const hypercrop = require('hypercrop') | |
5 | 5 … | const hyperlightbox = require('hyperlightbox') | |
6 | -const Mutual = require('ssb-mutual') | ||
7 | - | ||
8 | 6 … | const { | |
9 | - h, Value, Dict: MutantObject, Struct, | ||
10 | - map, computed, when, dictToCollection | ||
7 … | + h, Value, Dict, Struct, | ||
8 … | + map, computed, when, dictToCollection, onceTrue | ||
11 | 9 … | } = require('mutant') | |
12 | 10 … | const pull = require('pull-stream') | |
11 … | +const Mutual = require('ssb-mutual') | ||
13 | 12 … | ||
14 | 13 … | exports.gives = nest('about.html.edit') | |
15 | 14 … | ||
16 | 15 … | exports.needs = nest({ | |
@@ -38,13 +37,12 @@ | |||
38 | 37 … | ||
39 | 38 … | // TODO refactor this to use obs better | |
40 | 39 … | function edit (id) { | |
41 | 40 … | // TODO - get this to wait till the connection is present ! | |
42 | - var mutual = Mutual.init(api.sbot.obs.connection()) | ||
43 | 41 … | ||
44 | 42 … | var avatar = Struct({ | |
45 | 43 … | current: api.about.obs.imageUrl(id), | |
46 | - new: MutantObject() | ||
44 … | + new: Dict() | ||
47 | 45 … | }) | |
48 | 46 … | ||
49 | 47 … | const links = api.sbot.pull.links | |
50 | 48 … | ||
@@ -54,9 +52,9 @@ | |||
54 | 52 … | }) | |
55 | 53 … | ||
56 | 54 … | const images = computed(api.about.obs.groupedValues(id, 'image'), Object.keys) | |
57 | 55 … | ||
58 | - var namesRecord = MutantObject() | ||
56 … | + var namesRecord = Dict() | ||
59 | 57 … | // TODO constrain query to one name per peer? | |
60 | 58 … | pull( | |
61 | 59 … | links({dest: id, rel: 'about', values: true}), | |
62 | 60 … | pull.map(e => e.value.content.name), | |
@@ -83,18 +81,17 @@ | |||
83 | 81 … | if (name.new) return name.new | |
84 | 82 … | else return name.current | |
85 | 83 … | }) | |
86 | 84 … | ||
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 | ||
88 | 92 … | ||
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) | ||
97 | 94 … | }) | |
98 | 95 … | }) | |
99 | 96 … | ||
100 | 97 … | return h('AboutEditor', [ | |
@@ -108,9 +105,11 @@ | |||
108 | 105 … | h('section.description', computed(api.about.obs.description(id), (descr) => { | |
109 | 106 … | if (descr == null) return '' // TODO: should be in patchcore, I think... | |
110 | 107 … | return api.message.html.markdown(descr) | |
111 | 108 … | })), | |
112 | - h('section.credit', balances_div), | ||
109 … | + h('section.credit', map(dictToCollection(balances), balance => { | ||
110 … | + return h('div', ['💰 ', balance.value, ' ', balance.key]) | ||
111 … | + })), | ||
113 | 112 … | h('section.aliases', [ | |
114 | 113 … | h('header', 'Aliases'), | |
115 | 114 … | h('section.avatars', [ | |
116 | 115 … | h('header', 'Avatars'), |
background-process.js | ||
---|---|---|
@@ -12,17 +12,18 @@ | ||
12 | 12 … | .use(require('scuttlebot/plugins/local')) |
13 | 13 … | .use(require('scuttlebot/plugins/logging')) |
14 | 14 … | .use(require('ssb-about')) |
15 | 15 … | .use(require('ssb-backlinks')) |
16 … | + .use(require('ssb-blobs')) | |
17 … | + .use(require('ssb-chess-db')) | |
18 … | + .use(require('ssb-ebt')) | |
16 | 19 … | .use(require('ssb-friends')) |
20 … | + .use(require('ssb-meme')) | |
17 | 21 … | .use(require('ssb-private')) |
18 | - .use(require('ssb-blobs')) | |
22 … | + .use(require('ssb-query')) | |
19 | 23 … | .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')) | |
24 | 24 … | .use(require('ssb-ws')) |
25 … | + // .use(require('ssb-mutual')) // this is has recursion problems atm | |
25 | 26 … | |
26 | 27 … | // pull config options out of depject |
27 | 28 … | var config = require('./config').create().config.sync.load() |
28 | 29 … |
Built with git-ssb-web