git ssb

10+

Matt McKegg / patchwork



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 PM
Parent: 96998ccbab6e306591a3244a0f7c9e239d894ef2

Files changed

locales/en.jsonchanged
modules/feed/html/follow-warning.jschanged
modules/page/html/render/public.jschanged
modules/profile/obs/contact.jschanged
locales/en.jsonView
@@ -179,6 +179,9 @@
179179 "Browse Channels": "Browse Channels",
180180 "identifies ": "identifies ",
181181 " as \"": " as \"",
182182 "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."
184187 }
modules/feed/html/follow-warning.jsView
@@ -1,25 +1,44 @@
11 var nest = require('depnest')
2-var { when, h } = require('mutant')
2+var {
3+ when,
4+ h
5+} = require('mutant')
36
47 exports.needs = nest({
58 'intl.sync.i18n': 'first'
69 })
710
811 exports.gives = nest({
9- 'feed.html.followWarning': true
12+ 'feed.html.followWarning': true,
13+ 'feed.html.followerWarning': true
1014 })
1115
12-exports.create = function (api) {
16+exports.create = function(api) {
1317 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),
1732 h('p', explanation),
1833 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+ ])
2138 ]))
2239
2340 return when(condition, content)
24- })
41+ }
42+
43+
2544 }
modules/page/html/render/public.jsView
@@ -22,8 +22,9 @@
2222 'message.sync.root': 'first',
2323 'progress.html.peer': 'first',
2424
2525 'feed.html.followWarning': 'first',
26+ 'feed.html.followerWarning': 'first',
2627 'feed.html.rollup': 'first',
2728 'profile.obs.recentlyUpdated': 'first',
2829 'profile.obs.contact': 'first',
2930 'contact.obs.following': 'first',
@@ -62,9 +63,10 @@
6263 var contact = api.profile.obs.contact(id)
6364
6465 var prepend = [
6566 api.message.html.compose({ meta: { type: 'post' }, placeholder: i18n('Write a public message') }),
66- noVisibleNewPostsWarning()
67+ noVisibleNewPostsWarning(),
68+ noFollowersWarning()
6769 ]
6870
6971 var lastMessage = null
7072
@@ -266,13 +268,31 @@
266268 var explanation = i18n('You may not be able to see new content until you follow some users or pubs.')
267269
268270 var shownWhen = computed([loading, contact.isNotFollowingAnybody],
269271 (isLoading, isNotFollowingAnybody) => !isLoading && isNotFollowingAnybody
270- )
272+ )
271273
272274 return api.feed.html.followWarning(shownWhen, explanation)
273275 }
274276
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+
275295 function subscribe (id) {
276296 api.message.async.publish({
277297 type: 'channel',
278298 channel: id,
modules/profile/obs/contact.jsView
@@ -50,8 +50,12 @@
5050 var isNotFollowingAnybody = computed(following, followingList => {
5151 return !followingList || !followingList.length
5252 })
5353
54+ var hasNoFollowers = computed(followers, followersList => {
55+ return !followersList || !followersList.length
56+ })
57+
5458 return {
5559 followers,
5660 following,
5761 blockers,
@@ -64,8 +68,9 @@
6468 incomingVia,
6569 incomingViaCount: count(incomingVia),
6670 hasOutgoing,
6771 isNotFollowingAnybody,
72+ hasNoFollowers,
6873 noOutgoing: not(hasOutgoing, isYou),
6974 hasIncoming,
7075 noIncoming: not(hasIncoming, isYou),
7176 yourId,

Built with git-ssb-web