Files: 099482a819a132dc7efd6f1509ff5202e90d18f6 / main.js
1937 bytesRaw
1 | const combine = require('depject') |
2 | const entry = require('depject/entry') |
3 | const nest = require('depnest') |
4 | |
5 | // polyfills |
6 | require('setimmediate') |
7 | |
8 | // add inspect right click menu |
9 | require('./context-menu') |
10 | |
11 | // from more specialized to more general |
12 | const sockets = combine( |
13 | //need some modules first |
14 | { |
15 | settings: require('patch-settings'), |
16 | translations: require('./translations/sync'), |
17 | suggestions: require('patch-suggest'), // so that styles can be over-ridden |
18 | }, |
19 | { |
20 | about: require('./about'), |
21 | app: require('./app'), |
22 | blob: require('./blob'), |
23 | contact: require('./contact'), |
24 | //config: require('./ssb-config'), |
25 | config: require('./config'), |
26 | // group: require('./group'), |
27 | message: require('./message'), |
28 | router: require('./router'), |
29 | styles: require('./styles'), |
30 | state: require('./state/obs'), |
31 | unread: require('./unread'), |
32 | }, |
33 | { |
34 | blog: {html: { |
35 | post: require('./blog/html/post'), |
36 | blog: require('./blog/html/blog') |
37 | }} |
38 | }, |
39 | { |
40 | profile: require('patch-profile'), |
41 | history: require('patch-history'), |
42 | core: require('patchcore') |
43 | } |
44 | ) |
45 | |
46 | const api = entry(sockets, nest({ |
47 | 'app.html.app': 'first', |
48 | 'invite.async.autofollow': 'first', |
49 | 'config.sync.load': 'first', |
50 | 'sbot.async.friendsGet': 'first', |
51 | 'sbot.async.get': 'first' |
52 | })) |
53 | |
54 | document.body.appendChild(api.app.html.app()) |
55 | // console.log(api.config.sync.load()) |
56 | |
57 | var invite = api.config.sync.load().autoinvite |
58 | var self_id = api.config.sync.load().keys.id |
59 | if(invite) { |
60 | api.sbot.async.friendsGet({dest: self_id}, function (err, friends) { |
61 | //if you have less than 5 followers, maybe use the autoinvite |
62 | if(Object.keys(friends).length <= 5) |
63 | api.invite.async.autofollow( |
64 | invite, |
65 | function (err, follows) { console.log('autofollowed', err, follows) } |
66 | ) |
67 | else |
68 | console.log('no autoinvite - you have friends already') |
69 | }) |
70 | } |
71 | else |
72 | console.log('no invite') |
73 | |
74 |
Built with git-ssb-web