Commit f3592c5cbda2baabf9f84805e6b57b1912e93902
remove ssb-contacts dep, upgrade ssb-friends and use patchcore 1.12.1
ssbc/ssb-contacts#1 Hacked around lack of info about timestampsMatt McKegg committed on 9/29/2017, 11:05:28 AM
Parent: 9e3d2a27287664a8a12ac78c22384a9748102890
Files changed
modules/message/sheet/likes.js | changed |
modules/page/html/render/gatherings.js | changed |
modules/page/html/render/profile.js | changed |
modules/page/html/render/public.js | changed |
package.json | changed |
plugs/message/html/render/gathering.js | changed |
sbot/roots.js | changed |
server-process.js | changed |
modules/message/sheet/likes.js | ||
---|---|---|
@@ -52,9 +52,9 @@ | ||
52 | 52 | h('div', { |
53 | 53 | classList: 'ProfileList' |
54 | 54 | }, [ |
55 | 55 | map(profiles, (id) => { |
56 | - var following = computed(yourFollows, f => f.has(id)) | |
56 | + var following = computed(yourFollows, f => f.includes(id)) | |
57 | 57 | return h('a.profile', { |
58 | 58 | href: id, |
59 | 59 | classList: [ |
60 | 60 | when(following, '-following') |
modules/page/html/render/gatherings.js | ||
---|---|---|
@@ -35,9 +35,9 @@ | ||
35 | 35 | prepend, |
36 | 36 | bumpFilter: function (msg) { |
37 | 37 | if (msg.value && msg.value.content && typeof msg.value.content === 'object') { |
38 | 38 | var author = msg.value.author |
39 | - return id === author || following().has(author) | |
39 | + return id === author || following().includes(author) | |
40 | 40 | } |
41 | 41 | }, |
42 | 42 | rootFilter: (msg) => msg.value.content.type === 'gathering', |
43 | 43 | updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.latest({ids: [id]})) |
modules/page/html/render/profile.js | ||
---|---|---|
@@ -42,9 +42,9 @@ | ||
42 | 42 | var rawFollowing = api.contact.obs.following(id) |
43 | 43 | var friendsLoaded = computed([rawFollowers.sync, rawFollowing.sync], (...x) => x.every(Boolean)) |
44 | 44 | |
45 | 45 | var friends = computed([rawFollowing, rawFollowers], (following, followers) => { |
46 | - return Array.from(following).filter(follow => followers.has(follow)) | |
46 | + return Array.from(following).filter(follow => followers.includes(follow)) | |
47 | 47 | }) |
48 | 48 | |
49 | 49 | var following = computed([rawFollowing, friends], (following, friends) => { |
50 | 50 | return Array.from(following).filter(follow => !friends.includes(follow)) |
@@ -62,9 +62,9 @@ | ||
62 | 62 | return followsYou.includes(yourId) |
63 | 63 | }) |
64 | 64 | |
65 | 65 | var youFollow = computed([yourFollows], function (youFollow) { |
66 | - return youFollow.has(id) | |
66 | + return youFollow.includes(id) | |
67 | 67 | }) |
68 | 68 | |
69 | 69 | var names = api.about.obs.names(id) |
70 | 70 | var images = api.about.obs.images(id) |
@@ -199,9 +199,9 @@ | ||
199 | 199 | h('div', { |
200 | 200 | classList: 'ProfileList' |
201 | 201 | }, [ |
202 | 202 | map(profiles, (id) => { |
203 | - var following = computed(yourFollows, f => f.has(id)) | |
203 | + var following = computed(yourFollows, f => f.includes(id)) | |
204 | 204 | return h('a.profile', { |
205 | 205 | href: id, |
206 | 206 | classList: [ |
207 | 207 | when(following, '-following') |
modules/page/html/render/public.js | ||
---|---|---|
@@ -76,9 +76,9 @@ | ||
76 | 76 | |
77 | 77 | var author = msg.value.author |
78 | 78 | var channel = normalizeChannel(msg.value.content.channel) |
79 | 79 | var isSubscribed = channel ? subscribedChannels().has(channel) : false |
80 | - return isSubscribed || id === author || following().has(author) | |
80 | + return isSubscribed || id === author || following().includes(author) | |
81 | 81 | } |
82 | 82 | }, |
83 | 83 | rootFilter: function (msg) { |
84 | 84 | if (!filters()) return true |
@@ -106,9 +106,9 @@ | ||
106 | 106 | return result |
107 | 107 | |
108 | 108 | function getSidebar () { |
109 | 109 | var whoToFollow = computed([following, api.profile.obs.recentlyUpdated(), localPeers], (following, recent, peers) => { |
110 | - return recent.filter(x => x !== id && !following.has(x) && !peers.includes(x)).slice(0, 10) | |
110 | + return recent.filter(x => x !== id && !following.includes(x) && !peers.includes(x)).slice(0, 10) | |
111 | 111 | }) |
112 | 112 | return [ |
113 | 113 | h('button -pub -full', { |
114 | 114 | 'ev-click': api.invite.sheet |
package.json | ||
---|---|---|
@@ -36,9 +36,9 @@ | ||
36 | 36 | "mutant": "^3.21.2", |
37 | 37 | "mutant-pull-reduce": "^1.1.0", |
38 | 38 | "obv": "0.0.1", |
39 | 39 | "patch-settings": "^1.0.1", |
40 | - "patchcore": "~1.8.2", | |
40 | + "patchcore": "~1.12.1", | |
41 | 41 | "pull-abortable": "^4.1.0", |
42 | 42 | "pull-defer": "^0.2.2", |
43 | 43 | "pull-file": "~1.0.0", |
44 | 44 | "pull-identify-filetype": "^1.1.0", |
@@ -56,10 +56,9 @@ | ||
56 | 56 | "ssb-about": "0.1.0", |
57 | 57 | "ssb-avatar": "^0.2.0", |
58 | 58 | "ssb-backlinks": "~0.4.0", |
59 | 59 | "ssb-blobs": "~1.1.0", |
60 | - "ssb-contacts": "0.0.2", | |
61 | - "ssb-friends": "^2.1.0", | |
60 | + "ssb-friends": "^2.2.3", | |
62 | 61 | "ssb-keys": "~7.0.9", |
63 | 62 | "ssb-mentions": "^0.4.0", |
64 | 63 | "ssb-msgs": "^5.2.0", |
65 | 64 | "ssb-private": "0.1.2", |
plugs/message/html/render/gathering.js | ||
---|---|---|
@@ -122,9 +122,9 @@ | ||
122 | 122 | var yourId = api.keys.sync.id() |
123 | 123 | return computed([api.about.obs.name(id), id, following], function nameAndFollowWarning (name, id, following) { |
124 | 124 | if (id === yourId) { |
125 | 125 | return `${name} (you)` |
126 | - } else if (following.has(id)) { | |
126 | + } else if (following.includes(id)) { | |
127 | 127 | return `${name}` |
128 | 128 | } else { |
129 | 129 | return `${name} (not following)` |
130 | 130 | } |
sbot/roots.js | ||
---|---|---|
@@ -188,17 +188,17 @@ | ||
188 | 188 | } |
189 | 189 | |
190 | 190 | function getFilter (cb) { |
191 | 191 | // TODO: rewrite contacts stream |
192 | - ssb.contacts.get((err, contacts) => { | |
192 | + ssb.friends.get((err, friends) => { | |
193 | 193 | if (err) return cb(err) |
194 | 194 | ssb.patchwork.getSubscriptions((err, subscriptions) => { |
195 | 195 | if (err) return cb(err) |
196 | 196 | cb(null, function (ids, msg) { |
197 | 197 | var type = msg.value.content.type |
198 | 198 | if (type === 'vote') return false // filter out likes |
199 | 199 | var matchesChannel = (type !== 'channel' && checkChannel(subscriptions, ids, msg.value.content.channel)) |
200 | - return ids.includes(msg.value.author) || matchesChannel || checkFollowing(contacts, ids, msg.value.author) | |
200 | + return ids.includes(msg.value.author) || matchesChannel || checkFollowing(friends, ids, msg.value.author) | |
201 | 201 | }) |
202 | 202 | }) |
203 | 203 | }) |
204 | 204 | } |
@@ -206,9 +206,11 @@ | ||
206 | 206 | |
207 | 207 | function checkFollowing (lookup, ids, target) { |
208 | 208 | // TODO: rewrite contacts index (for some reason the order is different) |
209 | 209 | if (!lookup) return false |
210 | - var value = mostRecentValue(ids.map(id => lookup[id] && lookup[id].following && lookup[id].following[target]), 1) | |
210 | + // HACK: only lookup the first ID until a method is added to ssb-friends to | |
211 | + // correctly identify latest info | |
212 | + var value = ids.slice(0, 1).map(id => lookup[id] && lookup[id][target]) | |
211 | 213 | return value && value[0] |
212 | 214 | } |
213 | 215 | |
214 | 216 | function checkChannel (lookup, ids, channel) { |
server-process.js | ||
---|---|---|
@@ -17,9 +17,8 @@ | ||
17 | 17 | .use(require('scuttlebot/plugins/local')) |
18 | 18 | .use(require('scuttlebot/plugins/logging')) |
19 | 19 | .use(require('ssb-query')) |
20 | 20 | .use(require('ssb-about')) |
21 | - .use(require('ssb-contacts')) | |
22 | 21 | //.use(require('ssb-ebt')) // enable at your own risk! |
23 | 22 | .use(require('./sbot')) |
24 | 23 | |
25 | 24 | fixPath() |
Built with git-ssb-web