git ssb

2+

mixmix / ticktack



Commit ca44a0a40e4d24c2b6b42467fac6072170073817

add "default settings" so that theres a clear default selected for websharemetrics (and others)

mix irving committed on 5/8/2018, 7:48:19 AM
Parent: a3612acadbe16fef26a6e9762e666a8f8e68128f

Files changed

app/index.jschanged
app/page/settings.jschanged
app/sync/initialize/clickHandler.jschanged
app/sync/initialize/styles.jschanged
app/sync/initialize/suggests.jschanged
app/sync/initialize/zoomMemory.jschanged
app/sync/initialize/settings.jsadded
app/index.jsView
@@ -20,12 +20,12 @@
2020 sideNav: {
2121 addressBook: require('./html/sideNav/sideNavAddressBook'),
2222 discovery: require('./html/sideNav/sideNavDiscovery')
2323 },
24- warning: require('./html/warning'),
24+ warning: require('./html/warning')
2525 },
2626 obs: {
27- pluginsOk: require('./obs/pluginsOk'),
27+ pluginsOk: require('./obs/pluginsOk')
2828 },
2929 page: {
3030 addressBook: require('./page/addressBook'),
3131 blogIndex: require('./page/blogIndex'),
@@ -53,8 +53,9 @@
5353 },
5454 sync: {
5555 initialize: {
5656 clickHandler: require('./sync/initialize/clickHandler'),
57+ settings: require('./sync/initialize/settings'),
5758 styles: require('./sync/initialize/styles'),
5859 suggests: require('./sync/initialize/suggests'),
5960 zoomMemory: require('./sync/initialize/zoomMemory')
6061 }
app/page/settings.jsView
@@ -21,18 +21,12 @@
2121 })
2222
2323 const LANGUAGES = ['zh', 'en']
2424
25-// TODO - this needs moving somewhere upstream
26-// const DEFAULT_SETTINGS = {
27-// onboarded: false,
28-// language: 'zh'
29-// }
30-
3125 exports.create = (api) => {
3226 return nest('app.page.settings', settings)
3327
34- function settings(location) {
28+ function settings (location) {
3529 // RESET the app when the settings are changed
3630 api.settings.obs.get('language')(() => {
3731 console.log('language changed, resetting view')
3832
@@ -42,14 +36,13 @@
4236 ])
4337 api.history.sync.push({ page: 'settings' })
4438 })
4539
46- const webSharingMetricsOption = api.settings.obs.get('websharemetrics')
40+ const webSharingMetricsOption = api.settings.obs.get('ticktack.websharemetrics')
4741 const feed = api.keys.sync.id()
4842 const strings = api.translations.sync.strings()
4943 const currentLanguage = api.settings.sync.get('language')
5044
51-
5245 const editProfile = () => api.history.sync.push({
5346 page: 'userEdit',
5447 feed,
5548 callback: (err, didEdit) => {
@@ -102,9 +95,9 @@
10295 ])
10396 ])
10497 ])
10598
106- function Language(lang) {
99+ function Language (lang) {
107100 const selectLang = () => api.settings.sync.set({ language: lang })
108101 const className = currentLanguage === lang ? '-strong' : ''
109102
110103 return h('Button -language',
@@ -115,28 +108,28 @@
115108 strings.languages[lang]
116109 )
117110 }
118111
119- function zoomButton(increment, symbol) {
112+ function zoomButton (increment, symbol) {
120113 const { getCurrentWebContents } = electron.remote
121114 return h('Button -zoom',
122115 {
123116 'ev-click': () => {
124117 var zoomFactor = api.settings.sync.get('ticktack.electron.zoomFactor', 1)
125118 var newZoomFactor = zoomFactor + increment
126- var zoomFactor = api.settings.sync.set('ticktack.electron.zoomFactor', newZoomFactor)
119+ api.settings.sync.set('ticktack.electron.zoomFactor', newZoomFactor)
127120 getCurrentWebContents().setZoomFactor(newZoomFactor)
128121 }
129122 },
130123 symbol
131124 )
132125 }
133126
134- function webSharingOption(v, label) {
127+ function webSharingOption (v, label) {
135128 let myOption = computed(webSharingMetricsOption, opt => opt === v)
136129
137130 const selectWebSharingOption = () => {
138- api.settings.sync.set({ websharemetrics: v })
131+ webSharingMetricsOption.set(v)
139132 }
140133
141134 return h('Button -websharingmetrics',
142135 {
@@ -145,7 +138,6 @@
145138 },
146139 label
147140 )
148141 }
149-
150142 }
151143 }
app/sync/initialize/clickHandler.jsView
@@ -10,8 +10,9 @@
1010
1111 exports.create = (api) => {
1212 return nest({
1313 'app.sync.initialize': function initializeClickHandling () {
14+ console.log('> initialise: clickHandler')
1415 const target = document.body
1516
1617 api.app.async.catchLinkClick(target, (link, { isExternal }) => {
1718 if (isExternal) return openExternal(link)
app/sync/initialize/styles.jsView
@@ -10,8 +10,9 @@
1010
1111 exports.create = (api) => {
1212 return nest({
1313 'app.sync.initialize': function initializeStyles () {
14+ console.log('> initialise: styles')
1415 const css = values(api.styles.css()).join('\n')
1516 insertCss(css)
1617 }
1718 })
app/sync/initialize/suggests.jsView
@@ -12,8 +12,9 @@
1212 var nav = null
1313
1414 return nest({
1515 'app.sync.initialize': function initializeSuggests () {
16+ console.log('> initialise: suggest-mentions')
1617 api.about.async.suggest()
1718 api.channel.async.suggest()
1819 // api.channel.obs.recent()() TODO - figure out how to initialise this store
1920 }
app/sync/initialize/zoomMemory.jsView
@@ -11,8 +11,9 @@
1111 exports.create = (api) => {
1212 return nest('app.sync.initialize', zoomMemory)
1313
1414 function zoomMemory () {
15+ console.log('> initialise: window form')
1516 const { getCurrentWebContents, getCurrentWindow } = electron.remote
1617
1718 window.addEventListener('resize', () => {
1819 var wc = getCurrentWebContents()
app/sync/initialize/settings.jsView
@@ -1,0 +1,33 @@
1+const nest = require('depnest')
2+const merge = require('lodash/merge')
3+
4+exports.gives = nest('app.sync.initialize')
5+
6+exports.needs = nest({
7+ 'settings.sync.set': 'first',
8+ 'settings.sync.get': 'first'
9+})
10+
11+const defaults = {
12+ onboarded: false,
13+ language: 'en',
14+ ticktack: {
15+ websharemetrics: 'public',
16+ electron: {
17+ zoomFactor: 1
18+ }
19+ }
20+}
21+
22+exports.create = function (api) {
23+ return nest('app.sync.initialize', initialiseSettings)
24+
25+ function initialiseSettings () {
26+ console.log('> initialise: default settings')
27+ const { get, set } = api.settings.sync
28+ const settings = merge({}, defaults, get())
29+
30+ console.log('dog', settings)
31+ set(settings)
32+ }
33+}

Built with git-ssb-web