git ssb

10+

Matt McKegg / patchwork



Commit b6939f54fe19996c6c2471370cead05c07910c52

restructure settings and add default values

Matt McKegg committed on 12/12/2017, 2:27:48 AM
Parent: f06d537e3a5dcdce8c60eb9c129923924e3d7326

Files changed

modules/page/html/render/settings.jschanged
package.jsonchanged
plugs/intl/sync/i18n.jschanged
modules/page/html/render/settings.jsView
@@ -17,15 +17,17 @@
1717 return nest('page.html.render', function channel (path) {
1818 if (path !== '/settings') return
1919 const i18n = api.intl.sync.i18n
2020
21- const currentTheme = api.settings.obs.get('patchwork.theme')
22- const currentLang = api.settings.obs.get('patchwork.lang')
2321 const locales = api.intl.sync.locales()
2422 const localeNameLookup = api.intl.sync.localeNames()
25- const currentFontSize = api.settings.obs.get('patchwork.fontSize')
2623 const fontSizes = ['8px', '10px', '12px', '14px', '16px', '18px', '20px']
24 +
25 + const theme = api.settings.obs.get('patchwork.theme', 'light')
26 + const lang = api.settings.obs.get('patchwork.lang', '')
27 + const fontSize = api.settings.obs.get('patchwork.fontSize', '')
2728 const filterFollowing = api.settings.obs.get('filters.following')
29 + const onlySubscribed = api.settings.obs.get('filters.onlySubscribed')
2830
2931 var prepend = [
3032 h('PageHeading', [
3133 h('h1', [
@@ -41,31 +43,24 @@
4143
4244 h('section', [
4345 h('h2', i18n('Theme')),
4446 h('select', {
45- style: {
46- 'font-size': '120%'
47- },
48- value: when(currentTheme, currentTheme, 'light'),
49- 'ev-change': (ev) => api.settings.sync.set({
50- patchwork: {theme: ev.target.value}
51- })
47 + style: { 'font-size': '120%' },
48 + value: theme,
49 + 'ev-change': (ev) => theme.set(ev.target.value)
5250 }, [
5351 themeNames.map(name => h('option', {value: name}, [name]))
5452 ])
5553 ]),
5654
5755 h('section', [
5856 h('h2', i18n('Language')),
5957 h('select', {
60- style: {
61- 'font-size': '120%'
62- },
63- value: when(currentLang, currentLang, 'en'),
64- 'ev-change': (ev) => api.settings.sync.set({
65- patchwork: {lang: ev.target.value}
66- })
58 + style: { 'font-size': '120%' },
59 + value: lang,
60 + 'ev-change': (ev) => lang.set(ev.target.value)
6761 }, [
62 + h('option', {value: ''}, i18n('Default')),
6863 locales.map(code => h('option', {value: code}, [
6964 '[', code, '] ', getLocaleName(code)
7065 ]))
7166 ])
@@ -73,31 +68,27 @@
7368
7469 h('section', [
7570 h('h2', i18n('Font Size')),
7671 h('select', {
77- style: {
78- 'font-size': '120%'
79- },
80- value: when(currentFontSize, currentFontSize, ''),
81- 'ev-change': (ev) => api.settings.sync.set({
82- patchwork: {fontSize: ev.target.value}
83- })
72 + style: { 'font-size': '120%' },
73 + value: fontSize,
74 + 'ev-change': (ev) => fontSize.set(ev.target.value)
8475 }, [
85- h('option', {value: ''}, 'Default'),
76 + h('option', {value: ''}, i18n('Default')),
8677 fontSizes.map(size => h('option', {value: size}, size))
8778 ])
8879 ]),
8980
9081 h('section', [
91- h('h2', i18n('Filters')),
92- h('label', [
93- h('input', {
94- type: 'checkbox',
95- checked: filterFollowing,
96- 'ev-change': (ev) => api.settings.sync.set({
97- filters: {following: ev.target.checked}
98- })
99- }), i18n(' Hide following messages')
82 + h('h2', i18n('Public Feed Options')),
83 + h('div', [
84 + h('label', [
85 + h('input', {
86 + type: 'checkbox',
87 + checked: filterFollowing,
88 + 'ev-change': (ev) => filterFollowing.set(ev.target.checked)
89 + }), i18n(' Hide following messages')
90 + ])
10091 ])
10192 ])
10293 ])
10394 ])
package.jsonView
@@ -39,9 +39,9 @@
3939 "moment": "^2.18.1",
4040 "mutant": "^3.21.2",
4141 "mutant-pull-reduce": "^1.1.0",
4242 "obv": "0.0.1",
43- "patch-settings": "^1.0.1",
43 + "patch-settings": "github:mmckegg/patch-settings#e808303e2d3e6c88519266e0d9e18a750dee97a2",
4444 "patchcore": "~1.21.0",
4545 "pull-abortable": "^4.1.0",
4646 "pull-defer": "^0.2.2",
4747 "pull-file": "~1.0.0",
plugs/intl/sync/i18n.jsView
@@ -90,9 +90,10 @@
9090 directory: appRoot + '/locales',
9191 defaultLocale: 'en'
9292 })
9393
94- watch(api.settings.obs.get('patchwork.lang', navigator.language), currentLocale => {
94 + watch(api.settings.obs.get('patchwork.lang'), currentLocale => {
95 + currentLocale = currentLocale || navigator.language
9596 var locales = i18nL.getLocales()
9697
9798 // Try BCP47 codes, otherwise load family language if exist
9899 if (locales.indexOf(currentLocale) !== -1) {
@@ -113,9 +114,9 @@
113114 }
114115
115116 // For now get only global languages
116117 function getSubLocal (loc) {
117- return loc.split('-')[0]
118 + return typeof loc === 'string' && loc.split('-')[0]
118119 }
119120
120121 function getSimilar (locales, option) {
121122 var reindexed = {}

Built with git-ssb-web