aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/AppStore.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-03-12 14:04:13 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-03-12 14:04:13 +0100
commit9af01849f895230ae60a635c9756a5e206aa0fa1 (patch)
treeb0b99f324c1a2e8c52e1fadf1152efac6d1028d2 /src/stores/AppStore.js
parentBump version to 5.0.1-beta.1 (diff)
parentMerge branch 'sergiughf-hotfix/update-electron' into develop (diff)
downloadferdium-app-9af01849f895230ae60a635c9756a5e206aa0fa1.tar.gz
ferdium-app-9af01849f895230ae60a635c9756a5e206aa0fa1.tar.zst
ferdium-app-9af01849f895230ae60a635c9756a5e206aa0fa1.zip
Merge branch 'develop' into release/5.0.1-beta.1
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r--src/stores/AppStore.js56
1 files changed, 14 insertions, 42 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index d933ca407..351ad6422 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -3,7 +3,6 @@ import {
3 action, computed, observable, reaction, 3 action, computed, observable, reaction,
4} from 'mobx'; 4} from 'mobx';
5import moment from 'moment'; 5import moment from 'moment';
6import key from 'keymaster';
7import { getDoNotDisturb } from '@meetfranz/electron-notification-state'; 6import { getDoNotDisturb } from '@meetfranz/electron-notification-state';
8import AutoLaunch from 'auto-launch'; 7import AutoLaunch from 'auto-launch';
9import prettyBytes from 'pretty-bytes'; 8import prettyBytes from 'pretty-bytes';
@@ -13,7 +12,7 @@ import { URL } from 'url';
13import Store from './lib/Store'; 12import Store from './lib/Store';
14import Request from './lib/Request'; 13import Request from './lib/Request';
15import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; 14import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config';
16import { isMac, isLinux, isWindows } from '../environment'; 15import { isMac } from '../environment';
17import locales from '../i18n/translations'; 16import locales from '../i18n/translations';
18import { gaEvent, gaPage } from '../lib/analytics'; 17import { gaEvent, gaPage } from '../lib/analytics';
19import { onVisibilityChange } from '../helpers/visibility-helper'; 18import { onVisibilityChange } from '../helpers/visibility-helper';
@@ -157,41 +156,6 @@ export default class AppStore extends Store {
157 this.stores.router.push(url); 156 this.stores.router.push(url);
158 }); 157 });
159 158
160 // Set active the next service
161 key(
162 '⌘+pagedown, ctrl+pagedown, ⌘+alt+right, ctrl+tab', () => {
163 this.actions.service.setActiveNext();
164 },
165 );
166
167 // Set active the prev service
168 key(
169 '⌘+pageup, ctrl+pageup, ⌘+alt+left, ctrl+shift+tab', () => {
170 this.actions.service.setActivePrev();
171 },
172 );
173
174 // Global Mute
175 key(
176 '⌘+shift+m ctrl+shift+m', () => {
177 this.actions.app.toggleMuteApp();
178 },
179 );
180
181 // We need to add an additional key listener for ctrl+ on windows. Otherwise only ctrl+shift+ would work
182 if (isWindows) {
183 key(
184 'ctrl+=', () => {
185 debug('Windows: zoom in via ctrl+');
186 const { webview } = this.stores.services.active;
187 webview.getZoomLevel((level) => {
188 // level 9 =~ +300% and setZoomLevel wouldnt zoom in further
189 if (level < 9) webview.setZoomLevel(level + 1);
190 });
191 },
192 );
193 }
194
195 this.locale = this._getDefaultLocale(); 159 this.locale = this._getDefaultLocale();
196 160
197 this._healthCheck(); 161 this._healthCheck();
@@ -221,7 +185,15 @@ export default class AppStore extends Store {
221 }) { 185 }) {
222 if (this.stores.settings.all.app.isAppMuted) return; 186 if (this.stores.settings.all.app.isAppMuted) return;
223 187
188 // TODO: is there a simple way to use blobs for notifications without storing them on disk?
189 if (options.icon.startsWith('blob:')) {
190 delete options.icon;
191 }
192
224 const notification = new window.Notification(title, options); 193 const notification = new window.Notification(title, options);
194
195 debug('New notification', title, options);
196
225 notification.onclick = (e) => { 197 notification.onclick = (e) => {
226 if (serviceId) { 198 if (serviceId) {
227 this.actions.service.sendIPCMessage({ 199 this.actions.service.sendIPCMessage({
@@ -231,12 +203,13 @@ export default class AppStore extends Store {
231 }); 203 });
232 204
233 this.actions.service.setActive({ serviceId }); 205 this.actions.service.setActive({ serviceId });
234 206 mainWindow.show();
235 if (isWindows) { 207 if (app.mainWindow.isMinimized()) {
236 mainWindow.restore(); 208 mainWindow.restore();
237 } else if (isLinux) {
238 mainWindow.show();
239 } 209 }
210 mainWindow.focus();
211
212 debug('Notification click handler');
240 } 213 }
241 }; 214 };
242 } 215 }
@@ -303,7 +276,6 @@ export default class AppStore extends Store {
303 276
304 @action _muteApp({ isMuted, overrideSystemMute = true }) { 277 @action _muteApp({ isMuted, overrideSystemMute = true }) {
305 this.isSystemMuteOverridden = overrideSystemMute; 278 this.isSystemMuteOverridden = overrideSystemMute;
306
307 this.actions.settings.update({ 279 this.actions.settings.update({
308 type: 'app', 280 type: 'app',
309 data: { 281 data: {