aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js14
-rw-r--r--src/stores/ServicesStore.js1
-rw-r--r--src/stores/SettingsStore.js26
-rw-r--r--src/stores/UserStore.js3
4 files changed, 16 insertions, 28 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index a51a3267f..162422017 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -334,10 +334,7 @@ export default class AppStore extends Store {
334 } 334 }
335 335
336 // Helpers 336 // Helpers
337 async _appStartsCounter() { 337 _appStartsCounter() {
338 // we need to wait until the settings request is resolved
339 await this.stores.settings.allSettingsRequest;
340
341 this.actions.settings.update({ 338 this.actions.settings.update({
342 settings: { 339 settings: {
343 appStarts: (this.stores.settings.all.appStarts || 0) + 1, 340 appStarts: (this.stores.settings.all.appStarts || 0) + 1,
@@ -348,10 +345,7 @@ export default class AppStore extends Store {
348 async _autoStart() { 345 async _autoStart() {
349 this.autoLaunchOnStart = await this._checkAutoStart(); 346 this.autoLaunchOnStart = await this._checkAutoStart();
350 347
351 // we need to wait until the settings request is resolved 348 if (this.stores.settings.all.appStarts === 1) {
352 await this.stores.settings.allSettingsRequest;
353
354 if (!this.stores.settings.all.appStarts) {
355 this.actions.app.launchOnStartup({ 349 this.actions.app.launchOnStartup({
356 enable: true, 350 enable: true,
357 }); 351 });
@@ -367,8 +361,8 @@ export default class AppStore extends Store {
367 console.debug('reactivateServices: computer is offline, trying again in 5s, retries:', retryCount); 361 console.debug('reactivateServices: computer is offline, trying again in 5s, retries:', retryCount);
368 setTimeout(() => this._reactivateServices(retryCount + 1), 5000); 362 setTimeout(() => this._reactivateServices(retryCount + 1), 5000);
369 } else { 363 } else {
370 console.debug('reactivateServices: reload all services'); 364 console.debug('reactivateServices: reload Franz');
371 this.actions.service.reloadAll(); 365 window.location.reload();
372 } 366 }
373 } 367 }
374 368
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 99ffe5439..c38d0d9ee 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -536,7 +536,6 @@ export default class ServicesStore extends Store {
536 536
537 // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases 537 // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases
538 if (showMessageBadgesEvenWhenMuted) { 538 if (showMessageBadgesEvenWhenMuted) {
539 console.log('set badge', unreadDirectMessageCount, unreadIndirectMessageCount);
540 this.actions.app.setBadge({ 539 this.actions.app.setBadge({
541 unreadDirectMessageCount, 540 unreadDirectMessageCount,
542 unreadIndirectMessageCount, 541 unreadIndirectMessageCount,
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index da99a720f..b7d803398 100644
--- a/src/stores/SettingsStore.js
+++ b/src/stores/SettingsStore.js
@@ -1,17 +1,12 @@
1import { ipcRenderer } from 'electron'; 1import { ipcRenderer } from 'electron';
2import { action, computed, observable, extendObservable } from 'mobx'; 2import { action, computed } from 'mobx';
3import localStorage from 'mobx-localstorage';
3 4
4import Store from './lib/Store'; 5import Store from './lib/Store';
5import Request from './lib/Request';
6import CachedRequest from './lib/CachedRequest';
7import { gaEvent } from '../lib/analytics'; 6import { gaEvent } from '../lib/analytics';
8import SettingsModel from '../models/Settings'; 7import SettingsModel from '../models/Settings';
9 8
10export default class SettingsStore extends Store { 9export default class SettingsStore extends Store {
11 @observable allSettingsRequest = new CachedRequest(this.api.local, 'getSettings');
12 @observable updateSettingsRequest = new Request(this.api.local, 'updateSettings');
13 @observable removeSettingsKeyRequest = new Request(this.api.local, 'removeKey');
14
15 constructor(...args) { 10 constructor(...args) {
16 super(...args); 11 super(...args);
17 12
@@ -21,20 +16,16 @@ export default class SettingsStore extends Store {
21 } 16 }
22 17
23 setup() { 18 setup() {
24 this.allSettingsRequest.execute();
25 this._shareSettingsWithMainProcess(); 19 this._shareSettingsWithMainProcess();
26 } 20 }
27 21
28 @computed get all() { 22 @computed get all() {
29 return new SettingsModel(this.allSettingsRequest.result); 23 return new SettingsModel(localStorage.getItem('app') || {});
30 } 24 }
31 25
32 @action async _update({ settings }) { 26 @action async _update({ settings }) {
33 await this.updateSettingsRequest.execute(settings)._promise; 27 const appSettings = this.all;
34 await this.allSettingsRequest.patch((result) => { 28 localStorage.setItem('app', Object.assign(appSettings, settings));
35 if (!result) return;
36 extendObservable(result, settings);
37 });
38 29
39 // We need a little hack to wait until everything is patched 30 // We need a little hack to wait until everything is patched
40 setTimeout(() => this._shareSettingsWithMainProcess(), 0); 31 setTimeout(() => this._shareSettingsWithMainProcess(), 0);
@@ -43,8 +34,11 @@ export default class SettingsStore extends Store {
43 } 34 }
44 35
45 @action async _remove({ key }) { 36 @action async _remove({ key }) {
46 await this.removeSettingsKeyRequest.execute(key); 37 const appSettings = this.all;
47 await this.allSettingsRequest.invalidate({ immediately: true }); 38 if (Object.hasOwnProperty.call(appSettings, key)) {
39 delete appSettings[key];
40 localStorage.setItem('app', appSettings);
41 }
48 42
49 this._shareSettingsWithMainProcess(); 43 this._shareSettingsWithMainProcess();
50 } 44 }
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index abec4df5d..7dbbd955b 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -1,6 +1,7 @@
1import { observable, computed, action } from 'mobx'; 1import { observable, computed, action } from 'mobx';
2import moment from 'moment'; 2import moment from 'moment';
3import jwt from 'jsonwebtoken'; 3import jwt from 'jsonwebtoken';
4import localStorage from 'mobx-localstorage';
4 5
5import { isDevMode } from '../environment'; 6import { isDevMode } from '../environment';
6import Store from './lib/Store'; 7import Store from './lib/Store';
@@ -99,7 +100,7 @@ export default class UserStore extends Store {
99 100
100 // Data 101 // Data
101 @computed get isLoggedIn() { 102 @computed get isLoggedIn() {
102 return this.authToken !== null && this.authToken !== undefined; 103 return Boolean(localStorage.getItem('authToken'));
103 } 104 }
104 105
105 // @computed get isTokenValid() { 106 // @computed get isTokenValid() {