diff options
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r-- | src/stores/AppStore.js | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index cb8c71268..469e7519e 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -48,7 +48,8 @@ const autoLauncher = new AutoLaunch({ | |||
48 | path: executablePath, | 48 | path: executablePath, |
49 | }); | 49 | }); |
50 | 50 | ||
51 | const CATALINA_NOTIFICATION_HACK_KEY = '_temp_askedForCatalinaNotificationPermissions'; | 51 | const CATALINA_NOTIFICATION_HACK_KEY = |
52 | '_temp_askedForCatalinaNotificationPermissions'; | ||
52 | 53 | ||
53 | export default class AppStore extends Store { | 54 | export default class AppStore extends Store { |
54 | updateStatusTypes = { | 55 | updateStatusTypes = { |
@@ -92,8 +93,6 @@ export default class AppStore extends Store { | |||
92 | 93 | ||
93 | @observable isFocused = true; | 94 | @observable isFocused = true; |
94 | 95 | ||
95 | @observable nextAppReleaseVersion = null; | ||
96 | |||
97 | dictionaries = []; | 96 | dictionaries = []; |
98 | 97 | ||
99 | fetchDataInterval = null; | 98 | fetchDataInterval = null; |
@@ -175,7 +174,6 @@ export default class AppStore extends Store { | |||
175 | ipcRenderer.on('autoUpdate', (event, data) => { | 174 | ipcRenderer.on('autoUpdate', (event, data) => { |
176 | if (data.available) { | 175 | if (data.available) { |
177 | this.updateStatus = this.updateStatusTypes.AVAILABLE; | 176 | this.updateStatus = this.updateStatusTypes.AVAILABLE; |
178 | this.nextAppReleaseVersion = data.version; | ||
179 | if (isMac) { | 177 | if (isMac) { |
180 | app.dock.bounce(); | 178 | app.dock.bounce(); |
181 | } | 179 | } |
@@ -236,8 +234,8 @@ export default class AppStore extends Store { | |||
236 | this.actions.service.resetLastPollTimer(); | 234 | this.actions.service.resetLastPollTimer(); |
237 | 235 | ||
238 | if ( | 236 | if ( |
239 | this.timeSuspensionStart.add(10, 'm').isBefore(moment()) | 237 | this.timeSuspensionStart.add(10, 'm').isBefore(moment()) && |
240 | && this.stores.settings.app.get('reloadAfterResume') | 238 | this.stores.settings.app.get('reloadAfterResume') |
241 | ) { | 239 | ) { |
242 | debug('Reloading services, user info and features'); | 240 | debug('Reloading services, user info and features'); |
243 | 241 | ||
@@ -283,15 +281,15 @@ export default class AppStore extends Store { | |||
283 | ferdi: { | 281 | ferdi: { |
284 | version: ferdiVersion, | 282 | version: ferdiVersion, |
285 | electron: electronVersion, | 283 | electron: electronVersion, |
286 | installedRecipes: this.stores.recipes.all.map((recipe) => ({ | 284 | installedRecipes: this.stores.recipes.all.map(recipe => ({ |
287 | id: recipe.id, | 285 | id: recipe.id, |
288 | version: recipe.version, | 286 | version: recipe.version, |
289 | })), | 287 | })), |
290 | devRecipes: this.stores.recipePreviews.dev.map((recipe) => ({ | 288 | devRecipes: this.stores.recipePreviews.dev.map(recipe => ({ |
291 | id: recipe.id, | 289 | id: recipe.id, |
292 | version: recipe.version, | 290 | version: recipe.version, |
293 | })), | 291 | })), |
294 | services: this.stores.services.all.map((service) => ({ | 292 | services: this.stores.services.all.map(service => ({ |
295 | id: service.id, | 293 | id: service.id, |
296 | recipe: service.recipe.id, | 294 | recipe: service.recipe.id, |
297 | isAttached: service.isAttached, | 295 | isAttached: service.isAttached, |
@@ -302,7 +300,7 @@ export default class AppStore extends Store { | |||
302 | isDarkModeEnabled: service.isDarkModeEnabled, | 300 | isDarkModeEnabled: service.isDarkModeEnabled, |
303 | })), | 301 | })), |
304 | messages: this.stores.globalError.messages, | 302 | messages: this.stores.globalError.messages, |
305 | workspaces: this.stores.workspaces.workspaces.map((workspace) => ({ | 303 | workspaces: this.stores.workspaces.workspaces.map(workspace => ({ |
306 | id: workspace.id, | 304 | id: workspace.id, |
307 | services: workspace.services, | 305 | services: workspace.services, |
308 | })), | 306 | })), |
@@ -315,9 +313,7 @@ export default class AppStore extends Store { | |||
315 | } | 313 | } |
316 | 314 | ||
317 | // Actions | 315 | // Actions |
318 | @action _notify({ | 316 | @action _notify({ title, options, notificationId, serviceId = null }) { |
319 | title, options, notificationId, serviceId = null, | ||
320 | }) { | ||
321 | if (this.stores.settings.all.app.isAppMuted) return; | 317 | if (this.stores.settings.all.app.isAppMuted) return; |
322 | 318 | ||
323 | // TODO: is there a simple way to use blobs for notifications without storing them on disk? | 319 | // TODO: is there a simple way to use blobs for notifications without storing them on disk? |
@@ -359,8 +355,8 @@ export default class AppStore extends Store { | |||
359 | if (indicator === 0 && unreadIndirectMessageCount !== 0) { | 355 | if (indicator === 0 && unreadIndirectMessageCount !== 0) { |
360 | indicator = '•'; | 356 | indicator = '•'; |
361 | } else if ( | 357 | } else if ( |
362 | unreadDirectMessageCount === 0 | 358 | unreadDirectMessageCount === 0 && |
363 | && unreadIndirectMessageCount === 0 | 359 | unreadIndirectMessageCount === 0 |
364 | ) { | 360 | ) { |
365 | indicator = 0; | 361 | indicator = 0; |
366 | } else { | 362 | } else { |
@@ -441,22 +437,25 @@ export default class AppStore extends Store { | |||
441 | const clearAppCache = this.clearAppCacheRequest.execute(); | 437 | const clearAppCache = this.clearAppCacheRequest.execute(); |
442 | const allServiceIds = await getServiceIdsFromPartitions(); | 438 | const allServiceIds = await getServiceIdsFromPartitions(); |
443 | const allOrphanedServiceIds = allServiceIds.filter( | 439 | const allOrphanedServiceIds = allServiceIds.filter( |
444 | (id) => !this.stores.services.all.find( | 440 | id => |
445 | (s) => id.replace('service-', '') === s.id, | 441 | !this.stores.services.all.find( |
446 | ), | 442 | s => id.replace('service-', '') === s.id, |
443 | ), | ||
447 | ); | 444 | ); |
448 | 445 | ||
449 | try { | 446 | try { |
450 | await Promise.all( | 447 | await Promise.all( |
451 | allOrphanedServiceIds.map((id) => removeServicePartitionDirectory(id)), | 448 | allOrphanedServiceIds.map(id => removeServicePartitionDirectory(id)), |
452 | ); | 449 | ); |
453 | } catch (ex) { | 450 | } catch (ex) { |
454 | console.log('Error while deleting service partition directory - ', ex); | 451 | console.log('Error while deleting service partition directory - ', ex); |
455 | } | 452 | } |
456 | await Promise.all( | 453 | await Promise.all( |
457 | this.stores.services.all.map((s) => this.actions.service.clearCache({ | 454 | this.stores.services.all.map(s => |
458 | serviceId: s.id, | 455 | this.actions.service.clearCache({ |
459 | })), | 456 | serviceId: s.id, |
457 | }), | ||
458 | ), | ||
460 | ); | 459 | ); |
461 | 460 | ||
462 | await clearAppCache._promise; | 461 | await clearAppCache._promise; |
@@ -488,9 +487,9 @@ export default class AppStore extends Store { | |||
488 | } | 487 | } |
489 | 488 | ||
490 | if ( | 489 | if ( |
491 | locale | 490 | locale && |
492 | && Object.prototype.hasOwnProperty.call(locales, locale) | 491 | Object.prototype.hasOwnProperty.call(locales, locale) && |
493 | && locale !== this.locale | 492 | locale !== this.locale |
494 | ) { | 493 | ) { |
495 | this.locale = locale; | 494 | this.locale = locale; |
496 | } else if (!locale) { | 495 | } else if (!locale) { |
@@ -568,8 +567,8 @@ export default class AppStore extends Store { | |||
568 | const dnd = await ipcRenderer.invoke('get-dnd'); | 567 | const dnd = await ipcRenderer.invoke('get-dnd'); |
569 | debug('Do not disturb mode is', dnd); | 568 | debug('Do not disturb mode is', dnd); |
570 | if ( | 569 | if ( |
571 | dnd !== this.stores.settings.all.app.isAppMuted | 570 | dnd !== this.stores.settings.all.app.isAppMuted && |
572 | && !this.isSystemMuteOverridden | 571 | !this.isSystemMuteOverridden |
573 | ) { | 572 | ) { |
574 | this.actions.app.muteApp({ | 573 | this.actions.app.muteApp({ |
575 | isMuted: dnd, | 574 | isMuted: dnd, |