git ssb

10+

Matt McKegg / patchwork



Commit 2cb288a0dba6a17cd8c86c26d345d242585d25a5

fallback to "you follow x people that follow this person" when no mutual friends

Matt McKegg committed on 10/28/2017, 6:33:50 AM
Parent: 37f1f5982ffb6d545b8e4e7156aefa8285ecdc6b

Files changed

locales/en.jsonchanged
modules/page/html/render/profile.jschanged
modules/profile/html/preview.jschanged
modules/profile/obs/contact.jschanged
locales/en.jsonView
@@ -174,6 +174,11 @@
174174 "An error occured while publishing your message.": "An error occured while publishing your message.",
175175 "Missing message": "Missing message",
176176 " via ": " via ",
177177 "Cannot load thead": "Cannot load thead",
178- "The author of this message could be outside of your follow range or they may be blocked.": "The author of this message could be outside of your follow range or they may be blocked."
179-}
178+ "The author of this message could be outside of your follow range or they may be blocked.": "The author of this message could be outside of your follow range or they may be blocked.",
179+ "You follow %s people that follow this person.": {
180+ "one": "You follow someone that follows this person.",
181+ "other": "You follow %s people that follow this person."
182+ },
183+ "Followed by": "Followed by"
184+}
modules/page/html/render/profile.jsView
@@ -164,12 +164,22 @@
164164 when(contact.mutualFriendsCount,
165165 h('section -mutualFriends', [
166166 h('a', {
167167 href: '#',
168+ title: nameList(i18n('Mutual Friends'), contact.mutualFriends),
168169 'ev-click': send(displayMutualFriends, contact.mutualFriends)
169170 }, [
170171 '๐Ÿ‘ฅ ', computed(['You share %s mutual friends with this person.', contact.mutualFriendsCount], plural)
171172 ])
173+ ]),
174+ h('section -mutualFriends', [
175+ h('a', {
176+ href: '#',
177+ title: nameList(i18n('Followed by'), contact.incomingVia),
178+ 'ev-click': send(displayFollowedBy, contact.incomingVia)
179+ }, [
180+ '๐Ÿ‘ฅ ', computed(['You follow %s people that follow this person.', contact.incomingViaCount], plural)
181+ ])
172182 ])
173183 )
174184 )
175185 )
@@ -218,8 +228,12 @@
218228 container.reload = feedView.reload
219229 return container
220230 })
221231
232+ function displayFollowedBy (profiles) {
233+ api.sheet.profiles(profiles, i18n('Followed by'))
234+ }
235+
222236 function displayMutualFriends (profiles) {
223237 api.sheet.profiles(profiles, i18n('Mutual Friends'))
224238 }
225239
modules/profile/html/preview.jsView
@@ -1,6 +1,7 @@
11 var nest = require('depnest')
22 var h = require('mutant/h')
3+var map = require('mutant/map')
34 var when = require('mutant/when')
45 var computed = require('mutant/computed')
56 var send = require('mutant/send')
67
@@ -70,12 +71,22 @@
7071 when(contact.mutualFriendsCount,
7172 h('section -mutualFriends', [
7273 h('a', {
7374 href: '#',
75+ title: nameList(i18n('Mutual Friends'), contact.mutualFriends),
7476 'ev-click': send(displayMutualFriends, contact.mutualFriends)
7577 }, [
7678 '๐Ÿ‘ฅ ', computed(['You share %s mutual friends with this person.', contact.mutualFriendsCount], plural)
7779 ])
80+ ]),
81+ h('section -mutualFriends', [
82+ h('a', {
83+ href: '#',
84+ title: nameList(i18n('Followed by'), contact.incomingVia),
85+ 'ev-click': send(displayFollowedBy, contact.incomingVia)
86+ }, [
87+ '๐Ÿ‘ฅ ', computed(['You follow %s people that follow this person.', contact.incomingViaCount], plural)
88+ ])
7889 ])
7990 )
8091 )
8192 )
@@ -87,8 +98,19 @@
8798 function displayMutualFriends (profiles) {
8899 api.sheet.profiles(profiles, i18n('Mutual Friends'))
89100 }
90101
102+ function displayFollowedBy (profiles) {
103+ api.sheet.profiles(profiles, i18n('Followed by'))
104+ }
105+
91106 function displayBlockingFriends (profiles) {
92107 api.sheet.profiles(profiles, i18n('Blocked by'))
93108 }
109+
110+ function nameList (prefix, ids) {
111+ var items = map(ids, api.about.obs.name)
112+ return computed([prefix, items], (prefix, names) => {
113+ return (prefix ? (prefix + '\n') : '') + names.map((n) => `- ${n}`).join('\n')
114+ })
115+ }
94116 }
modules/profile/obs/contact.jsView
@@ -32,8 +32,11 @@
3232 })
3333
3434 var blockingFriends = computed([yourFollowers, yourFollowing, blockers], inAllSets)
3535 var mutualFriends = computed([yourFollowers, yourFollowing, followers, following], inAllSets)
36+ var outgoingVia = computed([yourFollowers, following], inAllSets)
37+ var incomingVia = computed([yourFollowing, followers], inAllSets)
38+
3639 var hasOutgoing = computed([yourFollowers, following], (a, b) => {
3740 return a.some((id) => b.includes(id))
3841 })
3942 var hasIncoming = computed([followers, yourFollowing], (a, b) => {
@@ -49,8 +52,12 @@
4952 blockingFriends,
5053 blockingFriendsCount: count(blockingFriends),
5154 mutualFriends,
5255 mutualFriendsCount: count(mutualFriends),
56+ outgoingVia,
57+ outgoingViaCount: count(outgoingVia),
58+ incomingVia,
59+ incomingViaCount: count(incomingVia),
5360 hasOutgoing,
5461 noOutgoing: not(hasOutgoing, isYou),
5562 hasIncoming,
5663 noIncoming: not(hasIncoming, isYou),

Built with git-ssb-web