Commit 04ed909259996b33de1dbd7bfdf406cef94b88dd
Utility function for shared code for rendering 'not following anyone' warning
Gordon Martin committed on 1/2/2018, 4:20:36 PMParent: 72e27cc7fada9532d1951f62691f02afd6b81b03
Files changed
locales/en.json | changed |
modules/feed/html/follow-warning.js | added |
modules/page/html/render/channel.js | changed |
modules/page/html/render/public.js | changed |
modules/profile/obs/contact.js | changed |
locales/en.json | ||
---|---|---|
@@ -136,6 +136,17 @@ | ||
136 | 136 | "Subscribed": "Subscribed", |
137 | 137 | "Write a message in this channel": "Write a message in this channel", |
138 | 138 | "mentioned this channel": "mentioned this channel", |
139 | 139 | "You are not Following Anyone": "You are not Following Anyone", |
140 | - "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." | |
140 | + "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.", | |
141 | + "Search Results:": "Search Results:", | |
142 | + "Search completed.": "Search completed.", | |
143 | + "result found": "result found", | |
144 | + "results found": "results found", | |
145 | + "blocked ": "blocked ", | |
146 | + "Confirm": "Confirm", | |
147 | + "Cancel": "Cancel", | |
148 | + "Unread Message": "Unread Message", | |
149 | + " forked this discussion:": " forked this discussion:", | |
150 | + "You are not following anyone": "You are not following anyone", | |
151 | + "For help getting started, see the guide at ": "For help getting started, see the guide at " | |
141 | 152 | } |
modules/feed/html/follow-warning.js | ||
---|---|---|
@@ -1,0 +1,27 @@ | ||
1 | +var nest = require('depnest') | |
2 | +var { when } = require('mutant') | |
3 | + | |
4 | +exports.needs = nest({ | |
5 | + 'intl.sync.i18n': 'first' | |
6 | +}) | |
7 | + | |
8 | +exports.gives = nest({ | |
9 | + 'feed.html.followWarning': true | |
10 | +}); | |
11 | + | |
12 | +exports.create = function(api) { | |
13 | + const i18n = api.intl.sync.i18n | |
14 | + return nest('feed.html.followWarning', function warning (condition, explanation) { | |
15 | + var content = | |
16 | + h('div', {classList: 'NotFollowingAnyoneWarning'}, h('section -notFollowingAnyoneWarning', [ | |
17 | + h('h1', i18n('You are not following anyone')), | |
18 | + h('p', explanation), | |
19 | + h('p', [i18n('For help getting started, see the guide at '), | |
20 | + h('a', {href: 'https://scuttlebutt.nz/getting-started.html'}, 'https://scuttlebutt.nz/getting-started.html')] | |
21 | + ), | |
22 | + ])) | |
23 | + | |
24 | + return when(condition, content); | |
25 | + }); | |
26 | + | |
27 | +} |
modules/page/html/render/channel.js | ||
---|---|---|
@@ -5,8 +5,9 @@ | ||
5 | 5 | 'channel.obs.subscribed': 'first', |
6 | 6 | 'message.html.compose': 'first', |
7 | 7 | 'channel.sync.normalize': 'first', |
8 | 8 | 'feed.html.rollup': 'first', |
9 | + 'feed.html.followWarning': 'first', | |
9 | 10 | 'feed.pull.channel': 'first', |
10 | 11 | 'sbot.pull.log': 'first', |
11 | 12 | 'message.async.publish': 'first', |
12 | 13 | 'keys.sync.id': 'first', |
@@ -77,18 +78,10 @@ | ||
77 | 78 | } |
78 | 79 | } |
79 | 80 | |
80 | 81 | function noVisibleNewPostsWarning() { |
81 | - var content = | |
82 | - h('div', {classList: 'NotFollowingAnyoneWarning'}, h('section -notFollowingAnyoneWarning', [ | |
83 | - h('h1', i18n('You are not Following Anyone')), | |
84 | - h('p', i18n('You may not be able to see new channel content until you follow some users or pubs.')), | |
85 | - h('p', [i18n("For help, see the 'Getting Started' guide at "), | |
86 | - h('a', {href: 'https://www.scuttlebutt.nz/'}, 'https://www.scuttlebutt.nz/')] | |
87 | - ), | |
88 | - ])) | |
89 | - | |
90 | - return when(contact.isNotFollowingAnybody, content) | |
82 | + var warning = i18n('You may not be able to see new channel content until you follow some users or pubs.') | |
83 | + return api.feed.html.followWarning(contact.isNotFollowingAnybody, warning); | |
91 | 84 | } |
92 | 85 | |
93 | 86 | }) |
94 | 87 |
modules/page/html/render/public.js | ||
---|---|---|
@@ -21,8 +21,9 @@ | ||
21 | 21 | 'message.async.publish': 'first', |
22 | 22 | 'message.sync.root': 'first', |
23 | 23 | 'progress.html.peer': 'first', |
24 | 24 | |
25 | + 'feed.html.followWarning': 'first', | |
25 | 26 | 'feed.html.rollup': 'first', |
26 | 27 | 'profile.obs.recentlyUpdated': 'first', |
27 | 28 | 'profile.obs.contact': 'first', |
28 | 29 | 'contact.obs.following': 'first', |
@@ -262,23 +263,15 @@ | ||
262 | 263 | ] |
263 | 264 | } |
264 | 265 | |
265 | 266 | function noVisibleNewPostsWarning() { |
266 | - var content = | |
267 | - h('div', {classList: 'NotFollowingAnyoneWarning'}, h('section -notFollowingAnyoneWarning', [ | |
268 | - h('h1', i18n('Welcome to Patchwork')), | |
269 | - h('p', i18n('You may not be able to see new content until you follow some users or pubs.')), | |
270 | - h('p', [i18n("For help, see the 'Getting Started' guide at "), | |
271 | - h('a', {href: 'https://www.scuttlebutt.nz/'}, 'https://www.scuttlebutt.nz/')] | |
272 | - ), | |
273 | - ])) | |
267 | + var explanation = i18n('You may not be able to see new content until you follow some users or pubs.') | |
268 | + | |
269 | + var shownWhen = computed([loading, contact.isNotFollowingAnybody], | |
270 | + (isLoading,isNotFollowingAnybody) => !isLoading && isNotFollowingAnybody | |
271 | + ) | |
274 | 272 | |
275 | - return when( | |
276 | - computed([loading, contact.isNotFollowingAnybody], | |
277 | - (isLoading,isNotFollowingAnybody) => !isLoading && isNotFollowingAnybody | |
278 | - ), | |
279 | - content | |
280 | - ) | |
273 | + return api.feed.html.followWarning(shownWhen, explanation); | |
281 | 274 | } |
282 | 275 | |
283 | 276 | function subscribe (id) { |
284 | 277 | api.message.async.publish({ |
modules/profile/obs/contact.js | ||
---|---|---|
@@ -45,9 +45,9 @@ | ||
45 | 45 | |
46 | 46 | var isYou = computed([yourId, id], (a, b) => a === b) |
47 | 47 | |
48 | 48 | var isNotFollowingAnybody = computed(following, |
49 | - followingList => (!followingList || followingList.length == 0) | |
49 | + followingList => !followingList || followingList.length == 0 | |
50 | 50 | ); |
51 | 51 | |
52 | 52 | return { |
53 | 53 | followers, |
Built with git-ssb-web