git ssb

10+

Matt McKegg / patchwork



Commit 04ed909259996b33de1dbd7bfdf406cef94b88dd

Utility function for shared code for rendering 'not following anyone' warning

Gordon Martin committed on 1/2/2018, 4:20:36 PM
Parent: 72e27cc7fada9532d1951f62691f02afd6b81b03

Files changed

locales/en.jsonchanged
modules/feed/html/follow-warning.jsadded
modules/page/html/render/channel.jschanged
modules/page/html/render/public.jschanged
modules/profile/obs/contact.jschanged
locales/en.jsonView
@@ -136,6 +136,17 @@
136136 "Subscribed": "Subscribed",
137137 "Write a message in this channel": "Write a message in this channel",
138138 "mentioned this channel": "mentioned this channel",
139139 "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 "
141152 }
modules/feed/html/follow-warning.jsView
@@ -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.jsView
@@ -5,8 +5,9 @@
55 'channel.obs.subscribed': 'first',
66 'message.html.compose': 'first',
77 'channel.sync.normalize': 'first',
88 'feed.html.rollup': 'first',
9+ 'feed.html.followWarning': 'first',
910 'feed.pull.channel': 'first',
1011 'sbot.pull.log': 'first',
1112 'message.async.publish': 'first',
1213 'keys.sync.id': 'first',
@@ -77,18 +78,10 @@
7778 }
7879 }
7980
8081 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);
9184 }
9285
9386 })
9487
modules/page/html/render/public.jsView
@@ -21,8 +21,9 @@
2121 'message.async.publish': 'first',
2222 'message.sync.root': 'first',
2323 'progress.html.peer': 'first',
2424
25+ 'feed.html.followWarning': 'first',
2526 'feed.html.rollup': 'first',
2627 'profile.obs.recentlyUpdated': 'first',
2728 'profile.obs.contact': 'first',
2829 'contact.obs.following': 'first',
@@ -262,23 +263,15 @@
262263 ]
263264 }
264265
265266 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+ )
274272
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);
281274 }
282275
283276 function subscribe (id) {
284277 api.message.async.publish({
modules/profile/obs/contact.jsView
@@ -45,9 +45,9 @@
4545
4646 var isYou = computed([yourId, id], (a, b) => a === b)
4747
4848 var isNotFollowingAnybody = computed(following,
49- followingList => (!followingList || followingList.length == 0)
49+ followingList => !followingList || followingList.length == 0
5050 );
5151
5252 return {
5353 followers,

Built with git-ssb-web