git ssb

10+

Matt McKegg / patchwork



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 timestamps
Matt McKegg committed on 9/29/2017, 11:05:28 AM
Parent: 9e3d2a27287664a8a12ac78c22384a9748102890

Files changed

modules/message/sheet/likes.jschanged
modules/page/html/render/gatherings.jschanged
modules/page/html/render/profile.jschanged
modules/page/html/render/public.jschanged
package.jsonchanged
plugs/message/html/render/gathering.jschanged
sbot/roots.jschanged
server-process.jschanged
modules/message/sheet/likes.jsView
@@ -52,9 +52,9 @@
5252 h('div', {
5353 classList: 'ProfileList'
5454 }, [
5555 map(profiles, (id) => {
56- var following = computed(yourFollows, f => f.has(id))
56+ var following = computed(yourFollows, f => f.includes(id))
5757 return h('a.profile', {
5858 href: id,
5959 classList: [
6060 when(following, '-following')
modules/page/html/render/gatherings.jsView
@@ -35,9 +35,9 @@
3535 prepend,
3636 bumpFilter: function (msg) {
3737 if (msg.value && msg.value.content && typeof msg.value.content === 'object') {
3838 var author = msg.value.author
39- return id === author || following().has(author)
39+ return id === author || following().includes(author)
4040 }
4141 },
4242 rootFilter: (msg) => msg.value.content.type === 'gathering',
4343 updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.latest({ids: [id]}))
modules/page/html/render/profile.jsView
@@ -42,9 +42,9 @@
4242 var rawFollowing = api.contact.obs.following(id)
4343 var friendsLoaded = computed([rawFollowers.sync, rawFollowing.sync], (...x) => x.every(Boolean))
4444
4545 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))
4747 })
4848
4949 var following = computed([rawFollowing, friends], (following, friends) => {
5050 return Array.from(following).filter(follow => !friends.includes(follow))
@@ -62,9 +62,9 @@
6262 return followsYou.includes(yourId)
6363 })
6464
6565 var youFollow = computed([yourFollows], function (youFollow) {
66- return youFollow.has(id)
66+ return youFollow.includes(id)
6767 })
6868
6969 var names = api.about.obs.names(id)
7070 var images = api.about.obs.images(id)
@@ -199,9 +199,9 @@
199199 h('div', {
200200 classList: 'ProfileList'
201201 }, [
202202 map(profiles, (id) => {
203- var following = computed(yourFollows, f => f.has(id))
203+ var following = computed(yourFollows, f => f.includes(id))
204204 return h('a.profile', {
205205 href: id,
206206 classList: [
207207 when(following, '-following')
modules/page/html/render/public.jsView
@@ -76,9 +76,9 @@
7676
7777 var author = msg.value.author
7878 var channel = normalizeChannel(msg.value.content.channel)
7979 var isSubscribed = channel ? subscribedChannels().has(channel) : false
80- return isSubscribed || id === author || following().has(author)
80+ return isSubscribed || id === author || following().includes(author)
8181 }
8282 },
8383 rootFilter: function (msg) {
8484 if (!filters()) return true
@@ -106,9 +106,9 @@
106106 return result
107107
108108 function getSidebar () {
109109 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)
111111 })
112112 return [
113113 h('button -pub -full', {
114114 'ev-click': api.invite.sheet
package.jsonView
@@ -36,9 +36,9 @@
3636 "mutant": "^3.21.2",
3737 "mutant-pull-reduce": "^1.1.0",
3838 "obv": "0.0.1",
3939 "patch-settings": "^1.0.1",
40- "patchcore": "~1.8.2",
40+ "patchcore": "~1.12.1",
4141 "pull-abortable": "^4.1.0",
4242 "pull-defer": "^0.2.2",
4343 "pull-file": "~1.0.0",
4444 "pull-identify-filetype": "^1.1.0",
@@ -56,10 +56,9 @@
5656 "ssb-about": "0.1.0",
5757 "ssb-avatar": "^0.2.0",
5858 "ssb-backlinks": "~0.4.0",
5959 "ssb-blobs": "~1.1.0",
60- "ssb-contacts": "0.0.2",
61- "ssb-friends": "^2.1.0",
60+ "ssb-friends": "^2.2.3",
6261 "ssb-keys": "~7.0.9",
6362 "ssb-mentions": "^0.4.0",
6463 "ssb-msgs": "^5.2.0",
6564 "ssb-private": "0.1.2",
plugs/message/html/render/gathering.jsView
@@ -122,9 +122,9 @@
122122 var yourId = api.keys.sync.id()
123123 return computed([api.about.obs.name(id), id, following], function nameAndFollowWarning (name, id, following) {
124124 if (id === yourId) {
125125 return `${name} (you)`
126- } else if (following.has(id)) {
126+ } else if (following.includes(id)) {
127127 return `${name}`
128128 } else {
129129 return `${name} (not following)`
130130 }
sbot/roots.jsView
@@ -188,17 +188,17 @@
188188 }
189189
190190 function getFilter (cb) {
191191 // TODO: rewrite contacts stream
192- ssb.contacts.get((err, contacts) => {
192+ ssb.friends.get((err, friends) => {
193193 if (err) return cb(err)
194194 ssb.patchwork.getSubscriptions((err, subscriptions) => {
195195 if (err) return cb(err)
196196 cb(null, function (ids, msg) {
197197 var type = msg.value.content.type
198198 if (type === 'vote') return false // filter out likes
199199 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)
201201 })
202202 })
203203 })
204204 }
@@ -206,9 +206,11 @@
206206
207207 function checkFollowing (lookup, ids, target) {
208208 // TODO: rewrite contacts index (for some reason the order is different)
209209 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])
211213 return value && value[0]
212214 }
213215
214216 function checkChannel (lookup, ids, channel) {
server-process.jsView
@@ -17,9 +17,8 @@
1717 .use(require('scuttlebot/plugins/local'))
1818 .use(require('scuttlebot/plugins/logging'))
1919 .use(require('ssb-query'))
2020 .use(require('ssb-about'))
21- .use(require('ssb-contacts'))
2221 //.use(require('ssb-ebt')) // enable at your own risk!
2322 .use(require('./sbot'))
2423
2524 fixPath()

Built with git-ssb-web