aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js7
-rw-r--r--src/stores/ServicesStore.js15
-rw-r--r--src/stores/UIStore.js7
-rw-r--r--src/stores/UserStore.js27
4 files changed, 46 insertions, 10 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index dd4642d70..b21d48a11 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -143,10 +143,13 @@ export default class AppStore extends Store {
143 143
144 // Handle deep linking (franz://) 144 // Handle deep linking (franz://)
145 ipcRenderer.on('navigateFromDeepLink', (event, data) => { 145 ipcRenderer.on('navigateFromDeepLink', (event, data) => {
146 const { url } = data; 146 debug('Navigate from deep link', data);
147 let { url } = data;
147 if (!url) return; 148 if (!url) return;
148 149
149 this.stores.router.push(data.url); 150 url = url.replace(/\/$/, '');
151
152 this.stores.router.push(url);
150 }); 153 });
151 154
152 // Set active the next service 155 // Set active the next service
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 0ab57312a..efd57a09d 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -70,6 +70,7 @@ export default class ServicesStore extends Store {
70 this._mapActiveServiceToServiceModelReaction.bind(this), 70 this._mapActiveServiceToServiceModelReaction.bind(this),
71 this._saveActiveService.bind(this), 71 this._saveActiveService.bind(this),
72 this._logoutReaction.bind(this), 72 this._logoutReaction.bind(this),
73 this._handleMuteSettings.bind(this),
73 ]); 74 ]);
74 75
75 // Just bind this 76 // Just bind this
@@ -627,6 +628,20 @@ export default class ServicesStore extends Store {
627 } 628 }
628 } 629 }
629 630
631 _handleMuteSettings() {
632 const { enabled } = this;
633 const { isAppMuted } = this.stores.settings.app;
634
635 enabled.forEach((service) => {
636 const { isAttached } = service;
637 const isMuted = isAppMuted || service.isMuted;
638
639 if (isAttached) {
640 service.webview.setAudioMuted(isMuted);
641 }
642 });
643 }
644
630 _shareSettingsWithServiceProcess() { 645 _shareSettingsWithServiceProcess() {
631 const settings = this.stores.settings.app; 646 const settings = this.stores.settings.app;
632 this.actions.service.sendIPCMessageToAllServices({ 647 this.actions.service.sendIPCMessageToAllServices({
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js
index d37ebe4c7..bb7965a4a 100644
--- a/src/stores/UIStore.js
+++ b/src/stores/UIStore.js
@@ -1,8 +1,7 @@
1import { action, observable, computed } from 'mobx'; 1import { action, observable, computed } from 'mobx';
2import { theme } from '@meetfranz/theme';
2 3
3import Store from './lib/Store'; 4import Store from './lib/Store';
4import * as themeDefault from '../theme/default';
5import * as themeDark from '../theme/dark';
6 5
7export default class UIStore extends Store { 6export default class UIStore extends Store {
8 @observable showServicesUpdatedInfoBar = false; 7 @observable showServicesUpdatedInfoBar = false;
@@ -24,10 +23,10 @@ export default class UIStore extends Store {
24 23
25 @computed get theme() { 24 @computed get theme() {
26 if (this.stores.settings.all.app.darkMode) { 25 if (this.stores.settings.all.app.darkMode) {
27 return Object.assign({}, themeDefault, themeDark); 26 return theme('dark');
28 } 27 }
29 28
30 return themeDefault; 29 return theme('default');
31 } 30 }
32 31
33 // Actions 32 // Actions
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index 7addb5760..77d84afe1 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -129,10 +129,6 @@ export default class UserStore extends Store {
129 return Boolean(localStorage.getItem('authToken')); 129 return Boolean(localStorage.getItem('authToken'));
130 } 130 }
131 131
132 // @computed get isTokenValid() {
133 // return this.authToken !== null && moment(this.tokenExpiry).isAfter(moment());
134 // }
135
136 @computed get isTokenExpired() { 132 @computed get isTokenExpired() {
137 if (!this.authToken) return false; 133 if (!this.authToken) return false;
138 134
@@ -160,6 +156,14 @@ export default class UserStore extends Store {
160 gaEvent('User', 'login'); 156 gaEvent('User', 'login');
161 } 157 }
162 158
159 @action _tokenLogin(authToken) {
160 this._setUserData(authToken);
161
162 this.stores.router.push('/');
163
164 gaEvent('User', 'tokenLogin');
165 }
166
163 @action async _signup({ 167 @action async _signup({
164 firstname, lastname, email, password, accountType, company, 168 firstname, lastname, email, password, accountType, company,
165 }) { 169 }) {
@@ -206,6 +210,8 @@ export default class UserStore extends Store {
206 } 210 }
207 211
208 @action async _update({ userData }) { 212 @action async _update({ userData }) {
213 if (!this.isLoggedIn) return;
214
209 const response = await this.updateUserInfoRequest.execute(userData)._promise; 215 const response = await this.updateUserInfoRequest.execute(userData)._promise;
210 216
211 this.getUserInfoRequest.patch(() => response.data); 217 this.getUserInfoRequest.patch(() => response.data);
@@ -222,6 +228,7 @@ export default class UserStore extends Store {
222 // workaround mobx issue 228 // workaround mobx issue
223 localStorage.removeItem('authToken'); 229 localStorage.removeItem('authToken');
224 window.localStorage.removeItem('authToken'); 230 window.localStorage.removeItem('authToken');
231
225 this.getUserInfoRequest.invalidate().reset(); 232 this.getUserInfoRequest.invalidate().reset();
226 this.authToken = null; 233 this.authToken = null;
227 } 234 }
@@ -262,6 +269,18 @@ export default class UserStore extends Store {
262 const { router } = this.stores; 269 const { router } = this.stores;
263 const currentRoute = router.location.pathname; 270 const currentRoute = router.location.pathname;
264 if (!this.isLoggedIn 271 if (!this.isLoggedIn
272 && currentRoute.includes('token=')) {
273 router.push(this.WELCOME_ROUTE);
274 const token = currentRoute.split('=')[1];
275
276 const data = this._parseToken(token);
277 if (data) {
278 // Give this some time to sink
279 setTimeout(() => {
280 this._tokenLogin(token);
281 }, 1000);
282 }
283 } else if (!this.isLoggedIn
265 && !currentRoute.includes(this.BASE_ROUTE)) { 284 && !currentRoute.includes(this.BASE_ROUTE)) {
266 router.push(this.WELCOME_ROUTE); 285 router.push(this.WELCOME_ROUTE);
267 } else if (this.isLoggedIn 286 } else if (this.isLoggedIn