Commit 45747ccda7b06223e42c0ead8833c062687d0d80
Merge branch 'ebt' into export-full
mix irving committed on 5/22/2018, 10:22:23 PMParent: 5d4d175f2895574c5670910407ca9436c1154f06
Parent: 275c10f68df818ea212601d260752d2256a9ce4e
Files changed
app/html/app.js | changed |
app/html/app.js | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | -const { h, Value } = require('mutant') | |
2 | +const { h, Value, onceTrue } = require('mutant') | |
3 | 3 | |
4 | 4 | exports.gives = nest('app.html.app') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
@@ -12,15 +12,17 @@ | ||
12 | 12 | 'keys.sync.id': 'first', |
13 | 13 | 'router.sync.router': 'first', |
14 | 14 | 'settings.sync.get': 'first', |
15 | 15 | 'settings.sync.set': 'first', |
16 | - | |
17 | 16 | 'invite.async.autofollow': 'first', |
18 | 17 | 'config.sync.load': 'first', |
19 | 18 | 'sbot.async.friendsGet': 'first', |
20 | - 'sbot.async.get': 'first' | |
19 | + 'sbot.async.get': 'first', | |
20 | + 'sbot.obs.connection': 'first' // EBT | |
21 | 21 | }) |
22 | 22 | |
23 | +var count = 0 // TODO - rm | |
24 | + | |
23 | 25 | exports.create = (api) => { |
24 | 26 | var view |
25 | 27 | |
26 | 28 | return nest({ |
@@ -33,12 +35,32 @@ | ||
33 | 35 | api.history.obs.location()(loc => console.log('location:', loc)) |
34 | 36 | |
35 | 37 | startApp() |
36 | 38 | |
39 | + onceTrue(api.sbot.obs.connection, server => getMySeq(server)) // EBT | |
40 | + | |
37 | 41 | return app |
38 | 42 | } |
39 | 43 | }) |
40 | 44 | |
45 | + function getMySeq (server) { | |
46 | + server.ebt.remoteFeedSequence((err, data) => { | |
47 | + server.latestSequence(server.id, (err, seq) => { | |
48 | + console.log(`${count} mins`) | |
49 | + count = count + 1 | |
50 | + console.log('actual seq:', seq) | |
51 | + console.log(JSON.stringify(data, null, 2)) | |
52 | + console.log('ticktack pubs', [ | |
53 | + '@7xMrWP8708+LDvaJrRMRQJEixWYp4Oipa9ohqY7+NyQ=.ed25519', | |
54 | + '@MflVZCcOBOUe6BLrm/8TyirkTu9/JtdnIJALcd8v5bc=.ed25519' | |
55 | + ]) | |
56 | + console.log('------------------') | |
57 | + }) | |
58 | + }) | |
59 | + | |
60 | + setTimeout(() => getMySeq(server), 60000) | |
61 | + } | |
62 | + | |
41 | 63 | function renderLocation (loc) { |
42 | 64 | var page = api.router.sync.router(loc) |
43 | 65 | if (page) { |
44 | 66 | view.set([ |
@@ -85,19 +107,25 @@ | ||
85 | 107 | console.log('no invites') |
86 | 108 | return |
87 | 109 | } |
88 | 110 | |
89 | - var self_id = api.config.sync.load().keys.id | |
90 | - api.sbot.async.friendsGet({dest: self_id}, function (err, friends) { | |
91 | - // if you have less than 5 followers, maybe use the autoinvite | |
92 | - if (Object.keys(friends).length <= 5) { | |
93 | - invites.forEach(invite => { | |
94 | - console.log('using invite:', invite) | |
95 | - api.invite.async.autofollow(invite, (err, follows) => { | |
96 | - if (err) console.error('Autofollow error:', err) | |
97 | - else console.log('Autofollow success', follows) | |
98 | - }) | |
111 | + useInvites(invites) | |
112 | + // TODO change it so that if you already have a bunch of friends you unfollow the pubs after they follow you? | |
113 | + | |
114 | + // var myKey = api.config.sync.load().keys.id | |
115 | + // api.sbot.async.friendsGet({dest: myKey}, function (err, friends) { | |
116 | + // // if you have less than 5 followers, maybe use the autoinvite | |
117 | + // if (Object.keys(friends).length <= 5) useInvites(invites) | |
118 | + // else console.log('no autoinvite - you have friends already') | |
119 | + // }) | |
120 | + | |
121 | + function useInvites (invites) { | |
122 | + invites.forEach(invite => { | |
123 | + console.log('using invite:', invite) | |
124 | + api.invite.async.autofollow(invite, (err, follows) => { | |
125 | + if (err) console.error('Autofollow error:', err) | |
126 | + else console.log('Autofollow success', follows) | |
99 | 127 | }) |
100 | - } else { console.log('no autoinvite - you have friends already') } | |
101 | - }) | |
128 | + }) | |
129 | + } | |
102 | 130 | } |
103 | 131 | } |
Built with git-ssb-web