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 AMParent: 37f1f5982ffb6d545b8e4e7156aefa8285ecdc6b
Files changed
locales/en.json | changed |
modules/page/html/render/profile.js | changed |
modules/profile/html/preview.js | changed |
modules/profile/obs/contact.js | changed |
locales/en.json | ||
---|---|---|
@@ -174,6 +174,11 @@ | ||
174 | 174 | "An error occured while publishing your message.": "An error occured while publishing your message.", |
175 | 175 | "Missing message": "Missing message", |
176 | 176 | " via ": " via ", |
177 | 177 | "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.js | ||
---|---|---|
@@ -164,12 +164,22 @@ | ||
164 | 164 | when(contact.mutualFriendsCount, |
165 | 165 | h('section -mutualFriends', [ |
166 | 166 | h('a', { |
167 | 167 | href: '#', |
168 | + title: nameList(i18n('Mutual Friends'), contact.mutualFriends), | |
168 | 169 | 'ev-click': send(displayMutualFriends, contact.mutualFriends) |
169 | 170 | }, [ |
170 | 171 | '๐ฅ ', computed(['You share %s mutual friends with this person.', contact.mutualFriendsCount], plural) |
171 | 172 | ]) |
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 | + ]) | |
172 | 182 | ]) |
173 | 183 | ) |
174 | 184 | ) |
175 | 185 | ) |
@@ -218,8 +228,12 @@ | ||
218 | 228 | container.reload = feedView.reload |
219 | 229 | return container |
220 | 230 | }) |
221 | 231 | |
232 | + function displayFollowedBy (profiles) { | |
233 | + api.sheet.profiles(profiles, i18n('Followed by')) | |
234 | + } | |
235 | + | |
222 | 236 | function displayMutualFriends (profiles) { |
223 | 237 | api.sheet.profiles(profiles, i18n('Mutual Friends')) |
224 | 238 | } |
225 | 239 |
modules/profile/html/preview.js | ||
---|---|---|
@@ -1,6 +1,7 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | 2 | var h = require('mutant/h') |
3 | +var map = require('mutant/map') | |
3 | 4 | var when = require('mutant/when') |
4 | 5 | var computed = require('mutant/computed') |
5 | 6 | var send = require('mutant/send') |
6 | 7 | |
@@ -70,12 +71,22 @@ | ||
70 | 71 | when(contact.mutualFriendsCount, |
71 | 72 | h('section -mutualFriends', [ |
72 | 73 | h('a', { |
73 | 74 | href: '#', |
75 | + title: nameList(i18n('Mutual Friends'), contact.mutualFriends), | |
74 | 76 | 'ev-click': send(displayMutualFriends, contact.mutualFriends) |
75 | 77 | }, [ |
76 | 78 | '๐ฅ ', computed(['You share %s mutual friends with this person.', contact.mutualFriendsCount], plural) |
77 | 79 | ]) |
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 | + ]) | |
78 | 89 | ]) |
79 | 90 | ) |
80 | 91 | ) |
81 | 92 | ) |
@@ -87,8 +98,19 @@ | ||
87 | 98 | function displayMutualFriends (profiles) { |
88 | 99 | api.sheet.profiles(profiles, i18n('Mutual Friends')) |
89 | 100 | } |
90 | 101 | |
102 | + function displayFollowedBy (profiles) { | |
103 | + api.sheet.profiles(profiles, i18n('Followed by')) | |
104 | + } | |
105 | + | |
91 | 106 | function displayBlockingFriends (profiles) { |
92 | 107 | api.sheet.profiles(profiles, i18n('Blocked by')) |
93 | 108 | } |
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 | + } | |
94 | 116 | } |
modules/profile/obs/contact.js | ||
---|---|---|
@@ -32,8 +32,11 @@ | ||
32 | 32 | }) |
33 | 33 | |
34 | 34 | var blockingFriends = computed([yourFollowers, yourFollowing, blockers], inAllSets) |
35 | 35 | var mutualFriends = computed([yourFollowers, yourFollowing, followers, following], inAllSets) |
36 | + var outgoingVia = computed([yourFollowers, following], inAllSets) | |
37 | + var incomingVia = computed([yourFollowing, followers], inAllSets) | |
38 | + | |
36 | 39 | var hasOutgoing = computed([yourFollowers, following], (a, b) => { |
37 | 40 | return a.some((id) => b.includes(id)) |
38 | 41 | }) |
39 | 42 | var hasIncoming = computed([followers, yourFollowing], (a, b) => { |
@@ -49,8 +52,12 @@ | ||
49 | 52 | blockingFriends, |
50 | 53 | blockingFriendsCount: count(blockingFriends), |
51 | 54 | mutualFriends, |
52 | 55 | mutualFriendsCount: count(mutualFriends), |
56 | + outgoingVia, | |
57 | + outgoingViaCount: count(outgoingVia), | |
58 | + incomingVia, | |
59 | + incomingViaCount: count(incomingVia), | |
53 | 60 | hasOutgoing, |
54 | 61 | noOutgoing: not(hasOutgoing, isYou), |
55 | 62 | hasIncoming, |
56 | 63 | noIncoming: not(hasIncoming, isYou), |
Built with git-ssb-web