Commit 899535c72ab24b5e7ae0e1494a2294297e31c4a4
Show a warning when the user has no followers (and has followed someone) to let them know their posts won't be visible to anyone.
Gordon Martin committed on 2/13/2018, 11:18:36 PMParent: 96998ccbab6e306591a3244a0f7c9e239d894ef2
Files changed
locales/en.json | changed |
modules/feed/html/follow-warning.js | changed |
modules/page/html/render/public.js | changed |
modules/profile/obs/contact.js | changed |
locales/en.json | ||
---|---|---|
@@ -179,6 +179,9 @@ | ||
179 | 179 | "Browse Channels": "Browse Channels", |
180 | 180 | "identifies ": "identifies ", |
181 | 181 | " as \"": " as \"", |
182 | 182 | "unblocked ": "unblocked ", |
183 | - "identified ": "identified " | |
183 | + "identified ": "identified ", | |
184 | + "Nobody will be able to see your posts until you have a follower. The easiest way to get a follower is to use a pub invite as the pub will follow you back. If you have already redeemed a pub invite and it has not followed you back, try another pub.": "Nobody will be able to see your posts until you have a follower. The easiest way to get a follower is to use a pub invite as the pub will follow you back. If you have already redeemed a pub invite and it has not followed you back, try another pub.", | |
185 | + "You have no followers": "You have no followers", | |
186 | + "Nobody will be able to see your posts until you have a follower. The easiest way to get a follower is to use a pub invite as the pub will follow you back. If you have already redeemed a pub invite and you see it has not followed you back on your profile, try another pub.": "Nobody will be able to see your posts until you have a follower. The easiest way to get a follower is to use a pub invite as the pub will follow you back. If you have already redeemed a pub invite and you see it has not followed you back on your profile, try another pub." | |
184 | 187 | } |
modules/feed/html/follow-warning.js | ||
---|---|---|
@@ -1,25 +1,44 @@ | ||
1 | 1 | var nest = require('depnest') |
2 | -var { when, h } = require('mutant') | |
2 | +var { | |
3 | + when, | |
4 | + h | |
5 | +} = require('mutant') | |
3 | 6 | |
4 | 7 | exports.needs = nest({ |
5 | 8 | 'intl.sync.i18n': 'first' |
6 | 9 | }) |
7 | 10 | |
8 | 11 | exports.gives = nest({ |
9 | - 'feed.html.followWarning': true | |
12 | + 'feed.html.followWarning': true, | |
13 | + 'feed.html.followerWarning': true | |
10 | 14 | }) |
11 | 15 | |
12 | -exports.create = function (api) { | |
16 | +exports.create = function(api) { | |
13 | 17 | const i18n = api.intl.sync.i18n |
14 | - return nest('feed.html.followWarning', function warning (condition, explanation) { | |
15 | - var content = h('div', {classList: 'NotFollowingAnyoneWarning'}, h('section', [ | |
16 | - h('h1', i18n('You are not following anyone')), | |
18 | + return nest('feed.html', { | |
19 | + followWarning: function followWarning(condition, explanation) { | |
20 | + return renderWarningBox(condition, i18n("You are not following anyone"), explanation) | |
21 | + }, | |
22 | + followerWarning: function followerWarning(condition, explanation) { | |
23 | + return renderWarningBox(condition, i18n("You have no followers"), explanation) | |
24 | + } | |
25 | + }) | |
26 | + | |
27 | + function renderWarningBox(condition, header, explanation) { | |
28 | + var content = h('div', { | |
29 | + classList: 'NotFollowingAnyoneWarning' | |
30 | + }, h('section', [ | |
31 | + h('h1', header), | |
17 | 32 | h('p', explanation), |
18 | 33 | h('p', [i18n('For help getting started, see the guide at '), |
19 | - h('a', {href: 'https://scuttlebutt.nz/getting-started.html'}, 'https://scuttlebutt.nz/getting-started.html')] | |
20 | - ) | |
34 | + h('a', { | |
35 | + href: 'https://scuttlebutt.nz/getting-started.html' | |
36 | + }, 'https://scuttlebutt.nz/getting-started.html') | |
37 | + ]) | |
21 | 38 | ])) |
22 | 39 | |
23 | 40 | return when(condition, content) |
24 | - }) | |
41 | + } | |
42 | + | |
43 | + | |
25 | 44 | } |
modules/page/html/render/public.js | ||
---|---|---|
@@ -22,8 +22,9 @@ | ||
22 | 22 | 'message.sync.root': 'first', |
23 | 23 | 'progress.html.peer': 'first', |
24 | 24 | |
25 | 25 | 'feed.html.followWarning': 'first', |
26 | + 'feed.html.followerWarning': 'first', | |
26 | 27 | 'feed.html.rollup': 'first', |
27 | 28 | 'profile.obs.recentlyUpdated': 'first', |
28 | 29 | 'profile.obs.contact': 'first', |
29 | 30 | 'contact.obs.following': 'first', |
@@ -62,9 +63,10 @@ | ||
62 | 63 | var contact = api.profile.obs.contact(id) |
63 | 64 | |
64 | 65 | var prepend = [ |
65 | 66 | api.message.html.compose({ meta: { type: 'post' }, placeholder: i18n('Write a public message') }), |
66 | - noVisibleNewPostsWarning() | |
67 | + noVisibleNewPostsWarning(), | |
68 | + noFollowersWarning() | |
67 | 69 | ] |
68 | 70 | |
69 | 71 | var lastMessage = null |
70 | 72 | |
@@ -266,13 +268,31 @@ | ||
266 | 268 | var explanation = i18n('You may not be able to see new content until you follow some users or pubs.') |
267 | 269 | |
268 | 270 | var shownWhen = computed([loading, contact.isNotFollowingAnybody], |
269 | 271 | (isLoading, isNotFollowingAnybody) => !isLoading && isNotFollowingAnybody |
270 | - ) | |
272 | + ) | |
271 | 273 | |
272 | 274 | return api.feed.html.followWarning(shownWhen, explanation) |
273 | 275 | } |
274 | 276 | |
277 | + function noFollowersWarning () { | |
278 | + | |
279 | + var explanation = i18n( | |
280 | + 'Nobody will be able to see your posts until you have a follower. The easiest way to get a follower is to use a pub invite as the pub will follow you back. If you have already redeemed a pub invite and you see it has not followed you back on your profile, try another pub.' | |
281 | + ) | |
282 | + | |
283 | + // We only show this if the user has followed someone as the first warning ('you are not followed anyone') | |
284 | + // should be sufficient to get the user to join a pub. However, pubs have been buggy and not followed back on occassion. | |
285 | + // Additionally, someone onboarded on a local network might follow someone on the network, but not be followed back by | |
286 | + // them, so we begin to show this warning if the user has followed someone, but has no followers. | |
287 | + var shownWhen = computed([loading, contact.hasNoFollowers, contact.isNotFollowingAnybody], | |
288 | + (isLoading, hasNoFollowers, isNotFollowingAnybody) => | |
289 | + !isLoading && (hasNoFollowers && !isNotFollowingAnybody) | |
290 | + ) | |
291 | + | |
292 | + return api.feed.html.followerWarning(shownWhen, explanation); | |
293 | + } | |
294 | + | |
275 | 295 | function subscribe (id) { |
276 | 296 | api.message.async.publish({ |
277 | 297 | type: 'channel', |
278 | 298 | channel: id, |
modules/profile/obs/contact.js | ||
---|---|---|
@@ -50,8 +50,12 @@ | ||
50 | 50 | var isNotFollowingAnybody = computed(following, followingList => { |
51 | 51 | return !followingList || !followingList.length |
52 | 52 | }) |
53 | 53 | |
54 | + var hasNoFollowers = computed(followers, followersList => { | |
55 | + return !followersList || !followersList.length | |
56 | + }) | |
57 | + | |
54 | 58 | return { |
55 | 59 | followers, |
56 | 60 | following, |
57 | 61 | blockers, |
@@ -64,8 +68,9 @@ | ||
64 | 68 | incomingVia, |
65 | 69 | incomingViaCount: count(incomingVia), |
66 | 70 | hasOutgoing, |
67 | 71 | isNotFollowingAnybody, |
72 | + hasNoFollowers, | |
68 | 73 | noOutgoing: not(hasOutgoing, isYou), |
69 | 74 | hasIncoming, |
70 | 75 | noIncoming: not(hasIncoming, isYou), |
71 | 76 | yourId, |
Built with git-ssb-web