git ssb

2+

mixmix / ticktack



Commit 0dbf73654513a31bdd3cab71a2047f263c054072

basic language settings toggleable

mix irving committed on 8/21/2017, 8:39:42 AM
Parent: 7d97c83df2eafb6c49340cb80ba64420cf4d764e

Files changed

app/html/header.jschanged
app/page/settings.jschanged
main.jschanged
package-lock.jsonchanged
package.jsonchanged
translations/sync.jschanged
app/html/header.jsView
@@ -15,9 +15,10 @@
1515 // h('h1', computed(nav.location, e => e.element.title)),
1616
1717 h('div.tools', [
1818 h('i.fa.fa-address-book', { 'ev-click': () => nav.push({page:'userFind'}) }),
19- h('i.fa.fa-hashtag', { 'ev-click': () => nav.push({page:'groupFind'}) })
19+ h('i.fa.fa-hashtag', { 'ev-click': () => nav.push({page:'groupFind'}) }),
20+ h('i.fa.fa-gear', { 'ev-click': () => nav.push({page:'settings'}) })
2021 ])
2122 ]),
2223 ])
2324 })
app/page/settings.jsView
@@ -3,20 +3,45 @@
33
44 exports.gives = nest('app.page.settings')
55
66 exports.needs = nest({
7+ 'settings.sync.get': 'first',
8+ 'settings.sync.set': 'first',
9+ 'settings.obs.get': 'first',
710 'translations.sync.strings': 'first',
811 })
912
13+const LANGUAGES = ['zh', 'en']
14+const DEFAULT_SETTINGS = {
15+ language: 'zh'
16+}
17+
1018 exports.create = (api) => {
1119 return nest('app.page.settings', settings)
1220
1321 function settings (location) {
22+ // RESET the app when the settings are changed
23+ api.settings.obs.get()(() => {
24+ window.location.reload()
25+ })
1426
15- return h('Page -settings', {title: strings.settings}, [
16- '****'
27+ const strings = api.translations.sync.strings()
28+ const currentLanguage = api.settings.sync.get('language')
29+
30+ function Language (lang) {
31+ const selectLang = () => api.settings.sync.set({ language: lang })
32+ const className = currentLanguage === lang ? '-primary' : ''
33+
34+ return h('div.language', { 'ev-click': () => selectLang(lang) },
35+ h('Button', { className }, lang)
36+ )
37+ }
38+
39+ return h('Page -settings', [
40+ h('div.container', [
41+ h('h1', strings.settings),
42+ h('div.languages', LANGUAGES.map(Language))
43+ ])
1744 ])
1845 }
1946 }
2047
21-
22-
main.jsView
@@ -9,11 +9,11 @@
99 require('./context-menu')
1010
1111 // from more specialized to more general
1212 const sockets = combine(
13+ require('patch-settings'),
1314 //we always need to have translations first!
14- {translations: require('./translations/sync')},
15- require('./unread'),
15+ { translations: require('./translations/sync') },
1616 {
1717 about: require('./about'),
1818 app: require('./app'),
1919 blob: require('./blob'),
@@ -24,8 +24,9 @@
2424 message: require('./message'),
2525 router: require('./router'),
2626 styles: require('./styles'),
2727 state: require('./state/obs'),
28+ unread: require('./unread'),
2829 },
2930 require('patchcore')
3031 )
3132
@@ -41,11 +42,4 @@
4142 function (err, follows) {
4243 console.log('autofollowed', err, follows);
4344 })
4445
45-
46-
47-
48-
49-
50-
51-
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 196213 bytes
New file size: 197011 bytes
package.jsonView
@@ -32,8 +32,9 @@
3232 "morphdom": "^2.3.3",
3333 "mutant": "^3.21.2",
3434 "obv-debounce": "^1.0.2",
3535 "open-external": "^0.1.1",
36+ "patch-settings": "^1.0.0",
3637 "patchcore": "^1.10.0",
3738 "pull-next": "^1.0.1",
3839 "pull-obv": "^1.3.0",
3940 "pull-stream": "^3.6.0",
translations/sync.jsView
@@ -2,16 +2,19 @@
22 const merge = require('lodash/merge')
33
44 exports.gives = nest('translations.sync.strings')
55
6-const en = require('./en.js')
7-const zh = require('./zh.js')
6+exports.needs = nest('settings.sync.get', 'first')
87
8+const languages = {
9+ en: require('./en.js'),
10+ zh: require('./zh.js')
11+}
12+
913 exports.create = (api) => {
10- // return nest('translations.sync.strings', () => en)
11-
1214 return nest('translations.sync.strings', () => {
13- return merge({}, en, zh)
15+ const language = api.settings.sync.get('language', 'zh')
16+
17+ return merge({}, languages.en, languages[language])
1418 })
1519 }
1620
17-

Built with git-ssb-web