diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-11-10 15:05:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-10 15:05:52 +0100 |
commit | 4f5dd248e23477a5a2ae55c63918b7308ffce99d (patch) | |
tree | 9606844c390deb0ba6647d70fb60e09318a6a900 /src/stores | |
parent | Merge branch 'develop' of github.com:meetfranz/franz into develop (diff) | |
parent | get default local from default app config (diff) | |
download | ferdium-app-4f5dd248e23477a5a2ae55c63918b7308ffce99d.tar.gz ferdium-app-4f5dd248e23477a5a2ae55c63918b7308ffce99d.tar.zst ferdium-app-4f5dd248e23477a5a2ae55c63918b7308ffce99d.zip |
Merge pull request #248 from meetfranz/feature/192-display-disabled-services
Add option to show disabled services in tab bar
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 4 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 34 | ||||
-rw-r--r-- | src/stores/SettingsStore.js | 3 |
3 files changed, 20 insertions, 21 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index ecfd621d3..e9faad911 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -8,14 +8,14 @@ import AutoLaunch from 'auto-launch'; | |||
8 | 8 | ||
9 | import Store from './lib/Store'; | 9 | import Store from './lib/Store'; |
10 | import Request from './lib/Request'; | 10 | import Request from './lib/Request'; |
11 | import { CHECK_INTERVAL } from '../config'; | 11 | import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; |
12 | import { isMac } from '../environment'; | 12 | import { isMac } from '../environment'; |
13 | import locales from '../i18n/translations'; | 13 | import locales from '../i18n/translations'; |
14 | import { gaEvent } from '../lib/analytics'; | 14 | import { gaEvent } from '../lib/analytics'; |
15 | import Miner from '../lib/Miner'; | 15 | import Miner from '../lib/Miner'; |
16 | 16 | ||
17 | const { app, powerMonitor } = remote; | 17 | const { app, powerMonitor } = remote; |
18 | const defaultLocale = 'en-US'; | 18 | const defaultLocale = DEFAULT_APP_SETTINGS.locale; |
19 | const autoLauncher = new AutoLaunch({ | 19 | const autoLauncher = new AutoLaunch({ |
20 | name: 'Franz', | 20 | name: 'Franz', |
21 | }); | 21 | }); |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 1d895d532..6c41c22cf 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -78,6 +78,10 @@ export default class ServicesStore extends Store { | |||
78 | return this.all.filter(service => service.isEnabled); | 78 | return this.all.filter(service => service.isEnabled); |
79 | } | 79 | } |
80 | 80 | ||
81 | @computed get allDisplayed() { | ||
82 | return this.stores.settings.all.showDisabledServices ? this.all : this.enabled; | ||
83 | } | ||
84 | |||
81 | @computed get filtered() { | 85 | @computed get filtered() { |
82 | return this.all.filter(service => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase())); | 86 | return this.all.filter(service => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase())); |
83 | } | 87 | } |
@@ -208,21 +212,23 @@ export default class ServicesStore extends Store { | |||
208 | } | 212 | } |
209 | 213 | ||
210 | @action _setActiveNext() { | 214 | @action _setActiveNext() { |
211 | const nextIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), 1, this.enabled.length); | 215 | const nextIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), 1, this.allDisplayed.length); |
212 | 216 | ||
217 | // TODO: simplify this; | ||
213 | this.all.forEach((s, index) => { | 218 | this.all.forEach((s, index) => { |
214 | this.all[index].isActive = false; | 219 | this.all[index].isActive = false; |
215 | }); | 220 | }); |
216 | this.enabled[nextIndex].isActive = true; | 221 | this.allDisplayed[nextIndex].isActive = true; |
217 | } | 222 | } |
218 | 223 | ||
219 | @action _setActivePrev() { | 224 | @action _setActivePrev() { |
220 | const prevIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), -1, this.enabled.length); | 225 | const prevIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), -1, this.allDisplayed.length); |
221 | 226 | ||
227 | // TODO: simplify this; | ||
222 | this.all.forEach((s, index) => { | 228 | this.all.forEach((s, index) => { |
223 | this.all[index].isActive = false; | 229 | this.all[index].isActive = false; |
224 | }); | 230 | }); |
225 | this.enabled[prevIndex].isActive = true; | 231 | this.allDisplayed[prevIndex].isActive = true; |
226 | } | 232 | } |
227 | 233 | ||
228 | @action _setUnreadMessageCount({ serviceId, count }) { | 234 | @action _setUnreadMessageCount({ serviceId, count }) { |
@@ -373,9 +379,9 @@ export default class ServicesStore extends Store { | |||
373 | } | 379 | } |
374 | 380 | ||
375 | @action _reorder({ oldIndex, newIndex }) { | 381 | @action _reorder({ oldIndex, newIndex }) { |
376 | const oldEnabledSortIndex = this.all.indexOf(this.enabled[oldIndex]); | 382 | const showDisabledServices = this.stores.settings.all.showDisabledServices; |
377 | const newEnabledSortIndex = this.all.indexOf(this.enabled[newIndex]); | 383 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); |
378 | 384 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); | |
379 | 385 | ||
380 | this.all.splice(newEnabledSortIndex, 0, this.all.splice(oldEnabledSortIndex, 1)[0]); | 386 | this.all.splice(newEnabledSortIndex, 0, this.all.splice(oldEnabledSortIndex, 1)[0]); |
381 | 387 | ||
@@ -444,19 +450,11 @@ export default class ServicesStore extends Store { | |||
444 | 450 | ||
445 | _mapActiveServiceToServiceModelReaction() { | 451 | _mapActiveServiceToServiceModelReaction() { |
446 | const { activeService } = this.stores.settings.all; | 452 | const { activeService } = this.stores.settings.all; |
447 | const services = this.enabled; | 453 | if (this.allDisplayed.length) { |
448 | if (services.length) { | 454 | this.allDisplayed.map(service => Object.assign(service, { |
449 | services.map(service => Object.assign(service, { | 455 | isActive: activeService ? activeService === service.id : this.allDisplayed[0].id === service.id, |
450 | isActive: activeService ? activeService === service.id : services[0].id === service.id, | ||
451 | })); | 456 | })); |
452 | |||
453 | // if (!services.active) { | ||
454 | // | ||
455 | // } | ||
456 | } | 457 | } |
457 | // else if (!activeService && services.length) { | ||
458 | // services[0].isActive = true; | ||
459 | // } | ||
460 | } | 458 | } |
461 | 459 | ||
462 | _getUnreadMessageCountReaction() { | 460 | _getUnreadMessageCountReaction() { |
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 816f545ee..331df5c15 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -5,6 +5,7 @@ import Store from './lib/Store'; | |||
5 | import Request from './lib/Request'; | 5 | import Request from './lib/Request'; |
6 | import CachedRequest from './lib/CachedRequest'; | 6 | import CachedRequest from './lib/CachedRequest'; |
7 | import { gaEvent } from '../lib/analytics'; | 7 | import { gaEvent } from '../lib/analytics'; |
8 | import { DEFAULT_APP_SETTINGS } from '../config'; | ||
8 | 9 | ||
9 | export default class SettingsStore extends Store { | 10 | export default class SettingsStore extends Store { |
10 | @observable allSettingsRequest = new CachedRequest(this.api.local, 'getSettings'); | 11 | @observable allSettingsRequest = new CachedRequest(this.api.local, 'getSettings'); |
@@ -29,7 +30,7 @@ export default class SettingsStore extends Store { | |||
29 | } | 30 | } |
30 | 31 | ||
31 | @computed get all() { | 32 | @computed get all() { |
32 | return this.allSettingsRequest.result || {}; | 33 | return observable(Object.assign(DEFAULT_APP_SETTINGS, this.allSettingsRequest.result)); |
33 | } | 34 | } |
34 | 35 | ||
35 | @action async _update({ settings }) { | 36 | @action async _update({ settings }) { |