summaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-11-10 15:05:52 +0100
committerLibravatar GitHub <noreply@github.com>2017-11-10 15:05:52 +0100
commit4f5dd248e23477a5a2ae55c63918b7308ffce99d (patch)
tree9606844c390deb0ba6647d70fb60e09318a6a900 /src/stores
parentMerge branch 'develop' of github.com:meetfranz/franz into develop (diff)
parentget default local from default app config (diff)
downloadferdium-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.js4
-rw-r--r--src/stores/ServicesStore.js34
-rw-r--r--src/stores/SettingsStore.js3
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
9import Store from './lib/Store'; 9import Store from './lib/Store';
10import Request from './lib/Request'; 10import Request from './lib/Request';
11import { CHECK_INTERVAL } from '../config'; 11import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config';
12import { isMac } from '../environment'; 12import { isMac } from '../environment';
13import locales from '../i18n/translations'; 13import locales from '../i18n/translations';
14import { gaEvent } from '../lib/analytics'; 14import { gaEvent } from '../lib/analytics';
15import Miner from '../lib/Miner'; 15import Miner from '../lib/Miner';
16 16
17const { app, powerMonitor } = remote; 17const { app, powerMonitor } = remote;
18const defaultLocale = 'en-US'; 18const defaultLocale = DEFAULT_APP_SETTINGS.locale;
19const autoLauncher = new AutoLaunch({ 19const 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';
5import Request from './lib/Request'; 5import Request from './lib/Request';
6import CachedRequest from './lib/CachedRequest'; 6import CachedRequest from './lib/CachedRequest';
7import { gaEvent } from '../lib/analytics'; 7import { gaEvent } from '../lib/analytics';
8import { DEFAULT_APP_SETTINGS } from '../config';
8 9
9export default class SettingsStore extends Store { 10export 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 }) {