From 899535c72ab24b5e7ae0e1494a2294297e31c4a4 Mon Sep 17 00:00:00 2001 From: Gordon Martin Date: Tue, 13 Feb 2018 23:18:36 +0000 Subject: [PATCH 1/5] 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. --- locales/en.json | 5 +++- modules/feed/html/follow-warning.js | 37 ++++++++++++++++++++++------- modules/page/html/render/public.js | 24 +++++++++++++++++-- modules/profile/obs/contact.js | 5 ++++ 4 files changed, 59 insertions(+), 12 deletions(-) diff --git a/locales/en.json b/locales/en.json index 9bd1c0909..e0b3fe14b 100644 --- a/locales/en.json +++ b/locales/en.json @@ -180,5 +180,8 @@ "identifies ": "identifies ", " as \"": " as \"", "unblocked ": "unblocked ", - "identified ": "identified " + "identified ": "identified ", + "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.", + "You have no followers": "You have no followers", + "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." } \ No newline at end of file diff --git a/modules/feed/html/follow-warning.js b/modules/feed/html/follow-warning.js index 49c74b48c..c6148c999 100644 --- a/modules/feed/html/follow-warning.js +++ b/modules/feed/html/follow-warning.js @@ -1,25 +1,44 @@ var nest = require('depnest') -var { when, h } = require('mutant') +var { + when, + h +} = require('mutant') exports.needs = nest({ 'intl.sync.i18n': 'first' }) exports.gives = nest({ - 'feed.html.followWarning': true + 'feed.html.followWarning': true, + 'feed.html.followerWarning': true }) -exports.create = function (api) { +exports.create = function(api) { const i18n = api.intl.sync.i18n - return nest('feed.html.followWarning', function warning (condition, explanation) { - var content = h('div', {classList: 'NotFollowingAnyoneWarning'}, h('section', [ - h('h1', i18n('You are not following anyone')), + return nest('feed.html', { + followWarning: function followWarning(condition, explanation) { + return renderWarningBox(condition, i18n("You are not following anyone"), explanation) + }, + followerWarning: function followerWarning(condition, explanation) { + return renderWarningBox(condition, i18n("You have no followers"), explanation) + } + }) + + function renderWarningBox(condition, header, explanation) { + var content = h('div', { + classList: 'NotFollowingAnyoneWarning' + }, h('section', [ + h('h1', header), h('p', explanation), h('p', [i18n('For help getting started, see the guide at '), - h('a', {href: 'https://scuttlebutt.nz/getting-started.html'}, 'https://scuttlebutt.nz/getting-started.html')] - ) + h('a', { + href: 'https://scuttlebutt.nz/getting-started.html' + }, 'https://scuttlebutt.nz/getting-started.html') + ]) ])) return when(condition, content) - }) + } + + } diff --git a/modules/page/html/render/public.js b/modules/page/html/render/public.js index d2f00bc9f..5edd22493 100644 --- a/modules/page/html/render/public.js +++ b/modules/page/html/render/public.js @@ -23,6 +23,7 @@ exports.needs = nest({ 'progress.html.peer': 'first', 'feed.html.followWarning': 'first', + 'feed.html.followerWarning': 'first', 'feed.html.rollup': 'first', 'profile.obs.recentlyUpdated': 'first', 'profile.obs.contact': 'first', @@ -63,7 +64,8 @@ exports.create = function (api) { var prepend = [ api.message.html.compose({ meta: { type: 'post' }, placeholder: i18n('Write a public message') }), - noVisibleNewPostsWarning() + noVisibleNewPostsWarning(), + noFollowersWarning() ] var lastMessage = null @@ -267,11 +269,29 @@ exports.create = function (api) { var shownWhen = computed([loading, contact.isNotFollowingAnybody], (isLoading, isNotFollowingAnybody) => !isLoading && isNotFollowingAnybody - ) + ) return api.feed.html.followWarning(shownWhen, explanation) } + function noFollowersWarning () { + + var explanation = i18n( + '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.' + ) + + // We only show this if the user has followed someone as the first warning ('you are not followed anyone') + // should be sufficient to get the user to join a pub. However, pubs have been buggy and not followed back on occassion. + // Additionally, someone onboarded on a local network might follow someone on the network, but not be followed back by + // them, so we begin to show this warning if the user has followed someone, but has no followers. + var shownWhen = computed([loading, contact.hasNoFollowers, contact.isNotFollowingAnybody], + (isLoading, hasNoFollowers, isNotFollowingAnybody) => + !isLoading && (hasNoFollowers && !isNotFollowingAnybody) + ) + + return api.feed.html.followerWarning(shownWhen, explanation); + } + function subscribe (id) { api.message.async.publish({ type: 'channel', diff --git a/modules/profile/obs/contact.js b/modules/profile/obs/contact.js index 87de444d2..f78575573 100644 --- a/modules/profile/obs/contact.js +++ b/modules/profile/obs/contact.js @@ -51,6 +51,10 @@ exports.create = function (api) { return !followingList || !followingList.length }) + var hasNoFollowers = computed(followers, followersList => { + return !followersList || !followersList.length + }) + return { followers, following, @@ -65,6 +69,7 @@ exports.create = function (api) { incomingViaCount: count(incomingVia), hasOutgoing, isNotFollowingAnybody, + hasNoFollowers, noOutgoing: not(hasOutgoing, isYou), hasIncoming, noIncoming: not(hasIncoming, isYou), From 1b50f4bc87538743de7931301f3b00f1ff1466d1 Mon Sep 17 00:00:00 2001 From: Gordon Martin Date: Wed, 14 Feb 2018 00:06:04 +0000 Subject: [PATCH 2/5] Fix formatting. --- index.js | 15 +++++++-------- locales/en.json | 15 ++++++++++++++- modules/feed/html/follow-warning.js | 14 ++++++-------- modules/page/html/render/public.js | 3 +-- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index 64923e0c5..1c44976a9 100644 --- a/index.js +++ b/index.js @@ -25,22 +25,21 @@ var quitting = false * we check if it's already running and if it is we focus the existing window * rather than opening a new instance. */ -function quitIfAlreadyRunning() { - var shouldQuit = electron.app.makeSingleInstance(function(commandLine, workingDirectory) { +function quitIfAlreadyRunning () { + var shouldQuit = electron.app.makeSingleInstance(function (commandLine, workingDirectory) { // Someone tried to run a second instance, we should focus our window. if (windows.main) { - if (windows.main.isMinimized()) windows.main.restore(); - windows.main.focus(); + if (windows.main.isMinimized()) windows.main.restore() + windows.main.focus() } - }); + }) if (shouldQuit) { - electron.app.quit(); - return; + electron.app.quit() } } -quitIfAlreadyRunning(); +quitIfAlreadyRunning() electron.app.on('ready', () => { setupContext('ssb', { diff --git a/locales/en.json b/locales/en.json index 1c28b85fa..1fe25ef31 100644 --- a/locales/en.json +++ b/locales/en.json @@ -100,5 +100,18 @@ " others": " others", "like": "like", "subscribed to ": "subscribed to ", - "liked this message": "liked this message" + "liked this message": "liked this message", + "Click to unblock": "Click to unblock", + "Blocked": "Blocked", + "Click to unfollow": "Click to unfollow", + "Follow Back": "Follow Back", + "Follow": "Follow", + "Click to block syncing with this person and hide their posts": "Click to block syncing with this person and hide their posts", + "Block": "Block", + "This is you.": "This is you.", + "unsubscribed from ": "unsubscribed from ", + "mentioned in your network": "mentioned in your network", + "on ": "on ", + "assigned a display image to ": "assigned a display image to ", + "Close": "Close" } \ No newline at end of file diff --git a/modules/feed/html/follow-warning.js b/modules/feed/html/follow-warning.js index c6148c999..06842b771 100644 --- a/modules/feed/html/follow-warning.js +++ b/modules/feed/html/follow-warning.js @@ -13,18 +13,18 @@ exports.gives = nest({ 'feed.html.followerWarning': true }) -exports.create = function(api) { +exports.create = function (api) { const i18n = api.intl.sync.i18n return nest('feed.html', { - followWarning: function followWarning(condition, explanation) { - return renderWarningBox(condition, i18n("You are not following anyone"), explanation) + followWarning: function followWarning (condition, explanation) { + return renderWarningBox(condition, i18n('You are not following anyone'), explanation) }, - followerWarning: function followerWarning(condition, explanation) { - return renderWarningBox(condition, i18n("You have no followers"), explanation) + followerWarning: function followerWarning (condition, explanation) { + return renderWarningBox(condition, i18n('You have no followers'), explanation) } }) - function renderWarningBox(condition, header, explanation) { + function renderWarningBox (condition, header, explanation) { var content = h('div', { classList: 'NotFollowingAnyoneWarning' }, h('section', [ @@ -39,6 +39,4 @@ exports.create = function(api) { return when(condition, content) } - - } diff --git a/modules/page/html/render/public.js b/modules/page/html/render/public.js index 5edd22493..fe44e6977 100644 --- a/modules/page/html/render/public.js +++ b/modules/page/html/render/public.js @@ -275,7 +275,6 @@ exports.create = function (api) { } function noFollowersWarning () { - var explanation = i18n( '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.' ) @@ -289,7 +288,7 @@ exports.create = function (api) { !isLoading && (hasNoFollowers && !isNotFollowingAnybody) ) - return api.feed.html.followerWarning(shownWhen, explanation); + return api.feed.html.followerWarning(shownWhen, explanation) } function subscribe (id) { From 2e2e0a092b955da7781f9a2347257017d8854de5 Mon Sep 17 00:00:00 2001 From: Gordon Martin Date: Wed, 14 Feb 2018 21:26:55 +0000 Subject: [PATCH 3/5] Fix formatting. --- locales/en.json | 30 ++++++++++++++++++++++++++++- modules/feed/html/follow-warning.js | 5 +---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/locales/en.json b/locales/en.json index 1fe25ef31..071976eed 100644 --- a/locales/en.json +++ b/locales/en.json @@ -113,5 +113,33 @@ "mentioned in your network": "mentioned in your network", "on ": "on ", "assigned a display image to ": "assigned a display image to ", - "Close": "Close" + "Close": "Close", + "Write a public message": "Write a public message", + "Missing message": "Missing message", + " via ": " via ", + "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.", + "New Message": "New Message", + "Write a private reply": "Write a private reply", + "Write a public reply": "Write a public reply", + "Confirm": "Confirm", + "Cancel": "Cancel", + "self assigned a description": "self assigned a description", + "self assigned a display image": "self assigned a display image", + "unfollowed ": "unfollowed ", + "Click to unsubscribe": "Click to unsubscribe", + "Subscribed": "Subscribed", + "Subscribe": "Subscribe", + "You follow %s people that subscribe to this channel.": { + "one": "You follow %s people that subscribe to this channel.", + "other": "You follow %s people that subscribe to this channel." + }, + "Write a message in this channel": "Write a message in this channel", + "You may not be able to see new channel content until you follow some users or pubs.": "You may not be able to see new channel content until you follow some users or pubs.", + "mentioned this channel": "mentioned this channel", + " forked this discussion:": " forked this discussion:", + "self identifies as ": "self identifies as ", + "%s people from your network replied to this message on ": { + "one": "%s people from your network replied to this message on ", + "other": "%s people from your network replied to this message on " + } } \ No newline at end of file diff --git a/modules/feed/html/follow-warning.js b/modules/feed/html/follow-warning.js index 06842b771..01b4b4d06 100644 --- a/modules/feed/html/follow-warning.js +++ b/modules/feed/html/follow-warning.js @@ -1,8 +1,5 @@ var nest = require('depnest') -var { - when, - h -} = require('mutant') +var { when, h } = require('mutant') exports.needs = nest({ 'intl.sync.i18n': 'first' From 10d7179c91530bc339270652277e99f17716fc99 Mon Sep 17 00:00:00 2001 From: Gordon Martin Date: Sun, 18 Feb 2018 10:21:48 +0000 Subject: [PATCH 4/5] Only show the 'no followers' warning if indexing has finished. --- modules/profile/obs/contact.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/profile/obs/contact.js b/modules/profile/obs/contact.js index 8a354b063..817647956 100644 --- a/modules/profile/obs/contact.js +++ b/modules/profile/obs/contact.js @@ -52,7 +52,7 @@ exports.create = function (api) { }) var hasNoFollowers = computed(followers, followersList => { - return !followersList || !followersList.length + return sync && (!followersList || !followersList.length) }) return { From 326fb93e823ad0d86a6ac3595ecdb6d267b01b8f Mon Sep 17 00:00:00 2001 From: Gordon Martin Date: Mon, 19 Feb 2018 11:45:54 +0000 Subject: [PATCH 5/5] Fix a couple of things based on hbett's code review: * An error in the code comments * Use 'const' over let in some functions I introduced. --- locales/en.json | 42 +++++++++++++++++++++++++++++- modules/page/html/render/public.js | 10 +++---- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/locales/en.json b/locales/en.json index 1c05aa3d8..dc7dcf609 100644 --- a/locales/en.json +++ b/locales/en.json @@ -103,5 +103,45 @@ "one": "%s people from your network replied to this message on ", "other": "%s people from your network replied to this message on " }, - "unfollowed ": "unfollowed " + "unfollowed ": "unfollowed ", + "subscribed to ": "subscribed to ", + "Write a public message": "Write a public message", + "Click to unsubscribe": "Click to unsubscribe", + "Subscribed": "Subscribed", + "Subscribe": "Subscribe", + "You follow %s people that subscribe to this channel.": { + "one": "You follow %s people that subscribe to this channel.", + "other": "You follow %s people that subscribe to this channel." + }, + "Write a message in this channel": "Write a message in this channel", + "You may not be able to see new channel content until you follow some users or pubs.": "You may not be able to see new channel content until you follow some users or pubs.", + "mentioned this channel": "mentioned this channel", + " others": " others", + "Click to unblock": "Click to unblock", + "Blocked": "Blocked", + "Click to unfollow": "Click to unfollow", + "Follow Back": "Follow Back", + "Follow": "Follow", + "Click to block syncing with this person and hide their posts": "Click to block syncing with this person and hide their posts", + "Block": "Block", + "This is you.": "This is you.", + "assigned a display image to ": "assigned a display image to ", + "Close": "Close", + "self identifies as ": "self identifies as ", + "New Message": "New Message", + "Write a private reply": "Write a private reply", + "Write a public reply": "Write a public reply", + "self assigned a description": "self assigned a description", + "liked this message": "liked this message", + "Confirm": "Confirm", + "Cancel": "Cancel", + "self assigned a display image": "self assigned a display image", + "Search Results:": "Search Results:", + "Search completed.": "Search completed.", + "result found": "result found", + "results found": "results found", + "Unread Message": "Unread Message", + " forked this discussion:": " forked this discussion:", + "on ": "on ", + "External Link": "External Link" } \ No newline at end of file diff --git a/modules/page/html/render/public.js b/modules/page/html/render/public.js index ebfcf4b51..2b6e0f9df 100644 --- a/modules/page/html/render/public.js +++ b/modules/page/html/render/public.js @@ -265,9 +265,9 @@ exports.create = function (api) { } function noVisibleNewPostsWarning () { - var explanation = i18n('You may not be able to see new content until you follow some users or pubs.') + const explanation = i18n('You may not be able to see new content until you follow some users or pubs.') - var shownWhen = computed([loading, contact.isNotFollowingAnybody], + const shownWhen = computed([loading, contact.isNotFollowingAnybody], (isLoading, isNotFollowingAnybody) => !isLoading && isNotFollowingAnybody ) @@ -275,15 +275,15 @@ exports.create = function (api) { } function noFollowersWarning () { - var explanation = i18n( + const explanation = i18n( '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.' ) - // We only show this if the user has followed someone as the first warning ('you are not followed anyone') + // We only show this if the user has followed someone as the first warning ('You are not following anyone') // should be sufficient to get the user to join a pub. However, pubs have been buggy and not followed back on occassion. // Additionally, someone onboarded on a local network might follow someone on the network, but not be followed back by // them, so we begin to show this warning if the user has followed someone, but has no followers. - var shownWhen = computed([loading, contact.hasNoFollowers, contact.isNotFollowingAnybody], + const shownWhen = computed([loading, contact.hasNoFollowers, contact.isNotFollowingAnybody], (isLoading, hasNoFollowers, isNotFollowingAnybody) => !isLoading && (hasNoFollowers && !isNotFollowingAnybody) )