diff options
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 105 | ||||
-rw-r--r-- | src/stores/NewsStore.js | 2 | ||||
-rw-r--r-- | src/stores/RecipePreviewsStore.js | 2 | ||||
-rw-r--r-- | src/stores/RecipesStore.js | 8 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 44 | ||||
-rw-r--r-- | src/stores/UIStore.js | 2 | ||||
-rw-r--r-- | src/stores/UserStore.js | 4 | ||||
-rw-r--r-- | src/stores/lib/CachedRequest.js | 4 | ||||
-rw-r--r-- | src/stores/lib/Reaction.js | 4 | ||||
-rw-r--r-- | src/stores/lib/Request.js | 2 | ||||
-rw-r--r-- | src/stores/lib/Store.js | 6 |
11 files changed, 104 insertions, 79 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index bbb5e6305..6b5ca7c9a 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -1,6 +1,11 @@ | |||
1 | import { ipcRenderer, shell } from 'electron'; | 1 | import { ipcRenderer, shell } from 'electron'; |
2 | import { | 2 | import { |
3 | app, screen, powerMonitor, nativeTheme, getCurrentWindow, process as remoteProcess, | 3 | app, |
4 | screen, | ||
5 | powerMonitor, | ||
6 | nativeTheme, | ||
7 | getCurrentWindow, | ||
8 | process as remoteProcess, | ||
4 | } from '@electron/remote'; | 9 | } from '@electron/remote'; |
5 | import { action, computed, observable } from 'mobx'; | 10 | import { action, computed, observable } from 'mobx'; |
6 | import moment from 'moment'; | 11 | import moment from 'moment'; |
@@ -14,13 +19,20 @@ import Store from './lib/Store'; | |||
14 | import Request from './lib/Request'; | 19 | import Request from './lib/Request'; |
15 | import { CHECK_INTERVAL } from '../config'; | 20 | import { CHECK_INTERVAL } from '../config'; |
16 | import { | 21 | import { |
17 | DEFAULT_APP_SETTINGS, isMac, ferdiVersion, electronVersion, osRelease, | 22 | DEFAULT_APP_SETTINGS, |
23 | isMac, | ||
24 | ferdiVersion, | ||
25 | electronVersion, | ||
26 | osRelease, | ||
18 | } from '../environment'; | 27 | } from '../environment'; |
19 | import locales from '../i18n/translations'; | 28 | import locales from '../i18n/translations'; |
20 | import { onVisibilityChange } from '../helpers/visibility-helper'; | 29 | import { onVisibilityChange } from '../helpers/visibility-helper'; |
21 | import { getLocale } from '../helpers/i18n-helpers'; | 30 | import { getLocale } from '../helpers/i18n-helpers'; |
22 | 31 | ||
23 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; | 32 | import { |
33 | getServiceIdsFromPartitions, | ||
34 | removeServicePartitionDirectory, | ||
35 | } from '../helpers/service-helpers'; | ||
24 | import { isValidExternalURL } from '../helpers/url-helpers'; | 36 | import { isValidExternalURL } from '../helpers/url-helpers'; |
25 | import { sleep } from '../helpers/async-helpers'; | 37 | import { sleep } from '../helpers/async-helpers'; |
26 | 38 | ||
@@ -49,7 +61,10 @@ export default class AppStore extends Store { | |||
49 | 61 | ||
50 | @observable healthCheckRequest = new Request(this.api.app, 'health'); | 62 | @observable healthCheckRequest = new Request(this.api.app, 'health'); |
51 | 63 | ||
52 | @observable getAppCacheSizeRequest = new Request(this.api.local, 'getAppCacheSize'); | 64 | @observable getAppCacheSizeRequest = new Request( |
65 | this.api.local, | ||
66 | 'getAppCacheSize', | ||
67 | ); | ||
53 | 68 | ||
54 | @observable clearAppCacheRequest = new Request(this.api.local, 'clearCache'); | 69 | @observable clearAppCacheRequest = new Request(this.api.local, 'clearCache'); |
55 | 70 | ||
@@ -93,7 +108,9 @@ export default class AppStore extends Store { | |||
93 | this.actions.app.openExternalUrl.listen(this._openExternalUrl.bind(this)); | 108 | this.actions.app.openExternalUrl.listen(this._openExternalUrl.bind(this)); |
94 | this.actions.app.checkForUpdates.listen(this._checkForUpdates.bind(this)); | 109 | this.actions.app.checkForUpdates.listen(this._checkForUpdates.bind(this)); |
95 | this.actions.app.installUpdate.listen(this._installUpdate.bind(this)); | 110 | this.actions.app.installUpdate.listen(this._installUpdate.bind(this)); |
96 | this.actions.app.resetUpdateStatus.listen(this._resetUpdateStatus.bind(this)); | 111 | this.actions.app.resetUpdateStatus.listen( |
112 | this._resetUpdateStatus.bind(this), | ||
113 | ); | ||
97 | this.actions.app.healthCheck.listen(this._healthCheck.bind(this)); | 114 | this.actions.app.healthCheck.listen(this._healthCheck.bind(this)); |
98 | this.actions.app.muteApp.listen(this._muteApp.bind(this)); | 115 | this.actions.app.muteApp.listen(this._muteApp.bind(this)); |
99 | this.actions.app.toggleMuteApp.listen(this._toggleMuteApp.bind(this)); | 116 | this.actions.app.toggleMuteApp.listen(this._toggleMuteApp.bind(this)); |
@@ -183,9 +200,7 @@ export default class AppStore extends Store { | |||
183 | // Handle deep linking (ferdi://) | 200 | // Handle deep linking (ferdi://) |
184 | ipcRenderer.on('navigateFromDeepLink', (event, data) => { | 201 | ipcRenderer.on('navigateFromDeepLink', (event, data) => { |
185 | debug('Navigate from deep link', data); | 202 | debug('Navigate from deep link', data); |
186 | let { | 203 | let { url } = data; |
187 | url, | ||
188 | } = data; | ||
189 | if (!url) return; | 204 | if (!url) return; |
190 | 205 | ||
191 | url = url.replace(/\/$/, ''); | 206 | url = url.replace(/\/$/, ''); |
@@ -221,7 +236,10 @@ export default class AppStore extends Store { | |||
221 | debug('System resumed, last suspended on', this.timeSuspensionStart); | 236 | debug('System resumed, last suspended on', this.timeSuspensionStart); |
222 | this.actions.service.resetLastPollTimer(); | 237 | this.actions.service.resetLastPollTimer(); |
223 | 238 | ||
224 | if (this.timeSuspensionStart.add(10, 'm').isBefore(moment()) && this.stores.settings.app.get('reloadAfterResume')) { | 239 | if ( |
240 | this.timeSuspensionStart.add(10, 'm').isBefore(moment()) | ||
241 | && this.stores.settings.app.get('reloadAfterResume') | ||
242 | ) { | ||
225 | debug('Reloading services, user info and features'); | 243 | debug('Reloading services, user info and features'); |
226 | 244 | ||
227 | setInterval(() => { | 245 | setInterval(() => { |
@@ -266,15 +284,15 @@ export default class AppStore extends Store { | |||
266 | ferdi: { | 284 | ferdi: { |
267 | version: ferdiVersion, | 285 | version: ferdiVersion, |
268 | electron: electronVersion, | 286 | electron: electronVersion, |
269 | installedRecipes: this.stores.recipes.all.map(recipe => ({ | 287 | installedRecipes: this.stores.recipes.all.map((recipe) => ({ |
270 | id: recipe.id, | 288 | id: recipe.id, |
271 | version: recipe.version, | 289 | version: recipe.version, |
272 | })), | 290 | })), |
273 | devRecipes: this.stores.recipePreviews.dev.map(recipe => ({ | 291 | devRecipes: this.stores.recipePreviews.dev.map((recipe) => ({ |
274 | id: recipe.id, | 292 | id: recipe.id, |
275 | version: recipe.version, | 293 | version: recipe.version, |
276 | })), | 294 | })), |
277 | services: this.stores.services.all.map(service => ({ | 295 | services: this.stores.services.all.map((service) => ({ |
278 | id: service.id, | 296 | id: service.id, |
279 | recipe: service.recipe.id, | 297 | recipe: service.recipe.id, |
280 | isAttached: service.isAttached, | 298 | isAttached: service.isAttached, |
@@ -285,11 +303,13 @@ export default class AppStore extends Store { | |||
285 | isDarkModeEnabled: service.isDarkModeEnabled, | 303 | isDarkModeEnabled: service.isDarkModeEnabled, |
286 | })), | 304 | })), |
287 | messages: this.stores.globalError.messages, | 305 | messages: this.stores.globalError.messages, |
288 | workspaces: this.stores.workspaces.workspaces.map(workspace => ({ | 306 | workspaces: this.stores.workspaces.workspaces.map((workspace) => ({ |
289 | id: workspace.id, | 307 | id: workspace.id, |
290 | services: workspace.services, | 308 | services: workspace.services, |
291 | })), | 309 | })), |
292 | windowSettings: readJsonSync(path.join(app.getPath('userData'), 'window-state.json')), | 310 | windowSettings: readJsonSync( |
311 | path.join(app.getPath('userData'), 'window-state.json'), | ||
312 | ), | ||
293 | settings, | 313 | settings, |
294 | features: this.stores.features.features, | 314 | features: this.stores.features.features, |
295 | user: this.stores.user.data.id, | 315 | user: this.stores.user.data.id, |
@@ -299,10 +319,7 @@ export default class AppStore extends Store { | |||
299 | 319 | ||
300 | // Actions | 320 | // Actions |
301 | @action _notify({ | 321 | @action _notify({ |
302 | title, | 322 | title, options, notificationId, serviceId = null, |
303 | options, | ||
304 | notificationId, | ||
305 | serviceId = null, | ||
306 | }) { | 323 | }) { |
307 | if (this.stores.settings.all.app.isAppMuted) return; | 324 | if (this.stores.settings.all.app.isAppMuted) return; |
308 | 325 | ||
@@ -339,15 +356,15 @@ export default class AppStore extends Store { | |||
339 | }; | 356 | }; |
340 | } | 357 | } |
341 | 358 | ||
342 | @action _setBadge({ | 359 | @action _setBadge({ unreadDirectMessageCount, unreadIndirectMessageCount }) { |
343 | unreadDirectMessageCount, | ||
344 | unreadIndirectMessageCount, | ||
345 | }) { | ||
346 | let indicator = unreadDirectMessageCount; | 360 | let indicator = unreadDirectMessageCount; |
347 | 361 | ||
348 | if (indicator === 0 && unreadIndirectMessageCount !== 0) { | 362 | if (indicator === 0 && unreadIndirectMessageCount !== 0) { |
349 | indicator = '•'; | 363 | indicator = '•'; |
350 | } else if (unreadDirectMessageCount === 0 && unreadIndirectMessageCount === 0) { | 364 | } else if ( |
365 | unreadDirectMessageCount === 0 | ||
366 | && unreadIndirectMessageCount === 0 | ||
367 | ) { | ||
351 | indicator = 0; | 368 | indicator = 0; |
352 | } else { | 369 | } else { |
353 | indicator = parseInt(indicator, 10); | 370 | indicator = parseInt(indicator, 10); |
@@ -358,9 +375,7 @@ export default class AppStore extends Store { | |||
358 | }); | 375 | }); |
359 | } | 376 | } |
360 | 377 | ||
361 | @action _launchOnStartup({ | 378 | @action _launchOnStartup({ enable }) { |
362 | enable, | ||
363 | }) { | ||
364 | this.autoLaunchOnStart = enable; | 379 | this.autoLaunchOnStart = enable; |
365 | 380 | ||
366 | try { | 381 | try { |
@@ -376,9 +391,7 @@ export default class AppStore extends Store { | |||
376 | } | 391 | } |
377 | } | 392 | } |
378 | 393 | ||
379 | @action _openExternalUrl({ | 394 | @action _openExternalUrl({ url }) { |
380 | url, | ||
381 | }) { | ||
382 | const parsedUrl = new URL(url); | 395 | const parsedUrl = new URL(url); |
383 | debug('open external url', parsedUrl); | 396 | debug('open external url', parsedUrl); |
384 | 397 | ||
@@ -414,10 +427,7 @@ export default class AppStore extends Store { | |||
414 | this.healthCheckRequest.execute(); | 427 | this.healthCheckRequest.execute(); |
415 | } | 428 | } |
416 | 429 | ||
417 | @action _muteApp({ | 430 | @action _muteApp({ isMuted, overrideSystemMute = true }) { |
418 | isMuted, | ||
419 | overrideSystemMute = true, | ||
420 | }) { | ||
421 | this.isSystemMuteOverridden = overrideSystemMute; | 431 | this.isSystemMuteOverridden = overrideSystemMute; |
422 | this.actions.settings.update({ | 432 | this.actions.settings.update({ |
423 | type: 'app', | 433 | type: 'app', |
@@ -437,16 +447,24 @@ export default class AppStore extends Store { | |||
437 | this.isClearingAllCache = true; | 447 | this.isClearingAllCache = true; |
438 | const clearAppCache = this.clearAppCacheRequest.execute(); | 448 | const clearAppCache = this.clearAppCacheRequest.execute(); |
439 | const allServiceIds = await getServiceIdsFromPartitions(); | 449 | const allServiceIds = await getServiceIdsFromPartitions(); |
440 | const allOrphanedServiceIds = allServiceIds.filter(id => !this.stores.services.all.find(s => id.replace('service-', '') === s.id)); | 450 | const allOrphanedServiceIds = allServiceIds.filter( |
451 | (id) => !this.stores.services.all.find( | ||
452 | (s) => id.replace('service-', '') === s.id, | ||
453 | ), | ||
454 | ); | ||
441 | 455 | ||
442 | try { | 456 | try { |
443 | await Promise.all(allOrphanedServiceIds.map(id => removeServicePartitionDirectory(id))); | 457 | await Promise.all( |
458 | allOrphanedServiceIds.map((id) => removeServicePartitionDirectory(id)), | ||
459 | ); | ||
444 | } catch (ex) { | 460 | } catch (ex) { |
445 | console.log('Error while deleting service partition directory - ', ex); | 461 | console.log('Error while deleting service partition directory - ', ex); |
446 | } | 462 | } |
447 | await Promise.all(this.stores.services.all.map(s => this.actions.service.clearCache({ | 463 | await Promise.all( |
448 | serviceId: s.id, | 464 | this.stores.services.all.map((s) => this.actions.service.clearCache({ |
449 | }))); | 465 | serviceId: s.id, |
466 | })), | ||
467 | ); | ||
450 | 468 | ||
451 | await clearAppCache._promise; | 469 | await clearAppCache._promise; |
452 | 470 | ||
@@ -476,7 +494,11 @@ export default class AppStore extends Store { | |||
476 | locale = this.stores.user.data.locale; | 494 | locale = this.stores.user.data.locale; |
477 | } | 495 | } |
478 | 496 | ||
479 | if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) { | 497 | if ( |
498 | locale | ||
499 | && Object.prototype.hasOwnProperty.call(locales, locale) | ||
500 | && locale !== this.locale | ||
501 | ) { | ||
480 | this.locale = locale; | 502 | this.locale = locale; |
481 | } else if (!locale) { | 503 | } else if (!locale) { |
482 | this.locale = this._getDefaultLocale(); | 504 | this.locale = this._getDefaultLocale(); |
@@ -553,7 +575,10 @@ export default class AppStore extends Store { | |||
553 | const dnd = await ipcRenderer.invoke('get-dnd'); | 575 | const dnd = await ipcRenderer.invoke('get-dnd'); |
554 | debug('Do not disturb mode is', dnd); | 576 | debug('Do not disturb mode is', dnd); |
555 | // ipcRenderer.on('autoUpdate', (event, data) => { | 577 | // ipcRenderer.on('autoUpdate', (event, data) => { |
556 | if (dnd !== this.stores.settings.all.app.isAppMuted && !this.isSystemMuteOverridden) { | 578 | if ( |
579 | dnd !== this.stores.settings.all.app.isAppMuted | ||
580 | && !this.isSystemMuteOverridden | ||
581 | ) { | ||
557 | this.actions.app.muteApp({ | 582 | this.actions.app.muteApp({ |
558 | isMuted: dnd, | 583 | isMuted: dnd, |
559 | overrideSystemMute: false, | 584 | overrideSystemMute: false, |
diff --git a/src/stores/NewsStore.js b/src/stores/NewsStore.js index 86e092592..66a17cb29 100644 --- a/src/stores/NewsStore.js +++ b/src/stores/NewsStore.js | |||
@@ -38,7 +38,7 @@ export default class NewsStore extends Store { | |||
38 | 38 | ||
39 | this.latestNewsRequest.invalidate().patch((result) => { | 39 | this.latestNewsRequest.invalidate().patch((result) => { |
40 | // TODO: check if we can use mobx.array remove | 40 | // TODO: check if we can use mobx.array remove |
41 | remove(result, n => n.id === newsId); | 41 | remove(result, (n) => n.id === newsId); |
42 | }); | 42 | }); |
43 | } | 43 | } |
44 | 44 | ||
diff --git a/src/stores/RecipePreviewsStore.js b/src/stores/RecipePreviewsStore.js index 989e1124a..10c170e81 100644 --- a/src/stores/RecipePreviewsStore.js +++ b/src/stores/RecipePreviewsStore.js | |||
@@ -31,7 +31,7 @@ export default class RecipePreviewsStore extends Store { | |||
31 | } | 31 | } |
32 | 32 | ||
33 | @computed get dev() { | 33 | @computed get dev() { |
34 | return this.stores.recipes.all.filter(r => r.local); | 34 | return this.stores.recipes.all.filter((r) => r.local); |
35 | } | 35 | } |
36 | 36 | ||
37 | // Actions | 37 | // Actions |
diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js index b49fb72d9..c7c4c1deb 100644 --- a/src/stores/RecipesStore.js +++ b/src/stores/RecipesStore.js | |||
@@ -54,11 +54,11 @@ export default class RecipesStore extends Store { | |||
54 | } | 54 | } |
55 | 55 | ||
56 | @computed get recipeIdForServices() { | 56 | @computed get recipeIdForServices() { |
57 | return this.stores.services.all.map(s => s.recipe.id); | 57 | return this.stores.services.all.map((s) => s.recipe.id); |
58 | } | 58 | } |
59 | 59 | ||
60 | one(id) { | 60 | one(id) { |
61 | return this.all.find(recipe => recipe.id === id); | 61 | return this.all.find((recipe) => recipe.id === id); |
62 | } | 62 | } |
63 | 63 | ||
64 | isInstalled(id) { | 64 | isInstalled(id) { |
@@ -78,7 +78,7 @@ export default class RecipesStore extends Store { | |||
78 | const recipes = {}; | 78 | const recipes = {}; |
79 | 79 | ||
80 | // Hackfix, reference this.all to fetch services | 80 | // Hackfix, reference this.all to fetch services |
81 | debug(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`); | 81 | debug(`Check Recipe updates for ${this.all.map((recipe) => recipe.id)}`); |
82 | 82 | ||
83 | recipeIds.forEach((r) => { | 83 | recipeIds.forEach((r) => { |
84 | const recipe = this.one(r); | 84 | const recipe = this.one(r); |
@@ -98,7 +98,7 @@ export default class RecipesStore extends Store { | |||
98 | const version = recipes[recipe]; | 98 | const version = recipes[recipe]; |
99 | 99 | ||
100 | // Find recipe in local recipe repository | 100 | // Find recipe in local recipe repository |
101 | const localRecipe = allJson.find(r => r.id === recipe); | 101 | const localRecipe = allJson.find((r) => r.id === recipe); |
102 | 102 | ||
103 | if (localRecipe && semver.lt(version, localRecipe.version)) { | 103 | if (localRecipe && semver.lt(version, localRecipe.version)) { |
104 | localUpdates.push(recipe); | 104 | localUpdates.push(recipe); |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index fa31dc292..fefcb5080 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -216,7 +216,7 @@ export default class ServicesStore extends Store { | |||
216 | } | 216 | } |
217 | 217 | ||
218 | @computed get enabled() { | 218 | @computed get enabled() { |
219 | return this.all.filter(service => service.isEnabled); | 219 | return this.all.filter((service) => service.isEnabled); |
220 | } | 220 | } |
221 | 221 | ||
222 | @computed get allDisplayed() { | 222 | @computed get allDisplayed() { |
@@ -229,7 +229,7 @@ export default class ServicesStore extends Store { | |||
229 | const { showDisabledServices } = this.stores.settings.all.app; | 229 | const { showDisabledServices } = this.stores.settings.all.app; |
230 | const { keepAllWorkspacesLoaded } = this.stores.workspaces.settings; | 230 | const { keepAllWorkspacesLoaded } = this.stores.workspaces.settings; |
231 | const services = this.allServicesRequest.execute().result || []; | 231 | const services = this.allServicesRequest.execute().result || []; |
232 | const filteredServices = showDisabledServices ? services : services.filter(service => service.isEnabled); | 232 | const filteredServices = showDisabledServices ? services : services.filter((service) => service.isEnabled); |
233 | 233 | ||
234 | let displayedServices; | 234 | let displayedServices; |
235 | if (keepAllWorkspacesLoaded) { | 235 | if (keepAllWorkspacesLoaded) { |
@@ -244,8 +244,8 @@ export default class ServicesStore extends Store { | |||
244 | // Check if workspace needs to be kept loaded | 244 | // Check if workspace needs to be kept loaded |
245 | if (workspace.services.includes(KEEP_WS_LOADED_USID)) { | 245 | if (workspace.services.includes(KEEP_WS_LOADED_USID)) { |
246 | // Get services for workspace | 246 | // Get services for workspace |
247 | const serviceIDs = workspace.services.filter(i => i !== KEEP_WS_LOADED_USID); | 247 | const serviceIDs = workspace.services.filter((i) => i !== KEEP_WS_LOADED_USID); |
248 | const wsServices = filteredServices.filter(service => serviceIDs.includes(service.id)); | 248 | const wsServices = filteredServices.filter((service) => serviceIDs.includes(service.id)); |
249 | 249 | ||
250 | displayedServices = [ | 250 | displayedServices = [ |
251 | ...displayedServices, | 251 | ...displayedServices, |
@@ -262,11 +262,11 @@ export default class ServicesStore extends Store { | |||
262 | } | 262 | } |
263 | 263 | ||
264 | @computed get filtered() { | 264 | @computed get filtered() { |
265 | return this.all.filter(service => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase())); | 265 | return this.all.filter((service) => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase())); |
266 | } | 266 | } |
267 | 267 | ||
268 | @computed get active() { | 268 | @computed get active() { |
269 | return this.all.find(service => service.isActive); | 269 | return this.all.find((service) => service.isActive); |
270 | } | 270 | } |
271 | 271 | ||
272 | @computed get activeSettings() { | 272 | @computed get activeSettings() { |
@@ -284,7 +284,7 @@ export default class ServicesStore extends Store { | |||
284 | } | 284 | } |
285 | 285 | ||
286 | @computed get isTodosServiceAdded() { | 286 | @computed get isTodosServiceAdded() { |
287 | return this.allDisplayed.find(service => service.isTodosService && service.isEnabled) || false; | 287 | return this.allDisplayed.find((service) => service.isTodosService && service.isEnabled) || false; |
288 | } | 288 | } |
289 | 289 | ||
290 | @computed get isTodosServiceActive() { | 290 | @computed get isTodosServiceActive() { |
@@ -292,7 +292,7 @@ export default class ServicesStore extends Store { | |||
292 | } | 292 | } |
293 | 293 | ||
294 | one(id) { | 294 | one(id) { |
295 | return this.all.find(service => service.id === id); | 295 | return this.all.find((service) => service.id === id); |
296 | } | 296 | } |
297 | 297 | ||
298 | async _showAddServiceInterface({ recipeId }) { | 298 | async _showAddServiceInterface({ recipeId }) { |
@@ -400,7 +400,7 @@ export default class ServicesStore extends Store { | |||
400 | newData.iconUrl = data.customIconUrl; | 400 | newData.iconUrl = data.customIconUrl; |
401 | } | 401 | } |
402 | 402 | ||
403 | Object.assign(result.find(c => c.id === serviceId), newData); | 403 | Object.assign(result.find((c) => c.id === serviceId), newData); |
404 | }); | 404 | }); |
405 | 405 | ||
406 | await request._promise; | 406 | await request._promise; |
@@ -434,7 +434,7 @@ export default class ServicesStore extends Store { | |||
434 | } | 434 | } |
435 | 435 | ||
436 | this.allServicesRequest.patch((result) => { | 436 | this.allServicesRequest.patch((result) => { |
437 | remove(result, c => c.id === serviceId); | 437 | remove(result, (c) => c.id === serviceId); |
438 | }); | 438 | }); |
439 | 439 | ||
440 | await request._promise; | 440 | await request._promise; |
@@ -493,7 +493,7 @@ export default class ServicesStore extends Store { | |||
493 | } | 493 | } |
494 | 494 | ||
495 | // Update list of last used services | 495 | // Update list of last used services |
496 | this.lastUsedServices = this.lastUsedServices.filter(id => id !== serviceId); | 496 | this.lastUsedServices = this.lastUsedServices.filter((id) => id !== serviceId); |
497 | this.lastUsedServices.unshift(serviceId); | 497 | this.lastUsedServices.unshift(serviceId); |
498 | 498 | ||
499 | this._focusActiveService(); | 499 | this._focusActiveService(); |
@@ -505,7 +505,7 @@ export default class ServicesStore extends Store { | |||
505 | } | 505 | } |
506 | 506 | ||
507 | @action _setActiveNext() { | 507 | @action _setActiveNext() { |
508 | const nextIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), 1, this.allDisplayed.length); | 508 | const nextIndex = this._wrapIndex(this.allDisplayed.findIndex((service) => service.isActive), 1, this.allDisplayed.length); |
509 | 509 | ||
510 | // TODO: simplify this; | 510 | // TODO: simplify this; |
511 | this.all.forEach((s, index) => { | 511 | this.all.forEach((s, index) => { |
@@ -515,7 +515,7 @@ export default class ServicesStore extends Store { | |||
515 | } | 515 | } |
516 | 516 | ||
517 | @action _setActivePrev() { | 517 | @action _setActivePrev() { |
518 | const prevIndex = this._wrapIndex(this.allDisplayed.findIndex(service => service.isActive), -1, this.allDisplayed.length); | 518 | const prevIndex = this._wrapIndex(this.allDisplayed.findIndex((service) => service.isActive), -1, this.allDisplayed.length); |
519 | 519 | ||
520 | // TODO: simplify this; | 520 | // TODO: simplify this; |
521 | this.all.forEach((s, index) => { | 521 | this.all.forEach((s, index) => { |
@@ -689,7 +689,7 @@ export default class ServicesStore extends Store { | |||
689 | } | 689 | } |
690 | 690 | ||
691 | @action _sendIPCMessageToAllServices({ channel, args }) { | 691 | @action _sendIPCMessageToAllServices({ channel, args }) { |
692 | this.all.forEach(s => this.actions.service.sendIPCMessage({ | 692 | this.all.forEach((s) => this.actions.service.sendIPCMessage({ |
693 | serviceId: s.id, | 693 | serviceId: s.id, |
694 | channel, | 694 | channel, |
695 | args, | 695 | args, |
@@ -740,7 +740,7 @@ export default class ServicesStore extends Store { | |||
740 | } | 740 | } |
741 | 741 | ||
742 | @action _reloadAll() { | 742 | @action _reloadAll() { |
743 | this.enabled.forEach(s => this._reload({ | 743 | this.enabled.forEach((s) => this._reload({ |
744 | serviceId: s.id, | 744 | serviceId: s.id, |
745 | })); | 745 | })); |
746 | } | 746 | } |
@@ -859,7 +859,7 @@ export default class ServicesStore extends Store { | |||
859 | }; | 859 | }; |
860 | 860 | ||
861 | if (!serviceId) { | 861 | if (!serviceId) { |
862 | this.allDisplayed.forEach(service => resetTimer(service)); | 862 | this.allDisplayed.forEach((service) => resetTimer(service)); |
863 | } else { | 863 | } else { |
864 | const service = this.one(serviceId); | 864 | const service = this.one(serviceId); |
865 | if (service) { | 865 | if (service) { |
@@ -893,7 +893,7 @@ export default class ServicesStore extends Store { | |||
893 | _mapActiveServiceToServiceModelReaction() { | 893 | _mapActiveServiceToServiceModelReaction() { |
894 | const { activeService } = this.stores.settings.all.service; | 894 | const { activeService } = this.stores.settings.all.service; |
895 | if (this.allDisplayed.length) { | 895 | if (this.allDisplayed.length) { |
896 | this.allDisplayed.map(service => Object.assign(service, { | 896 | this.allDisplayed.map((service) => Object.assign(service, { |
897 | isActive: activeService ? activeService === service.id : this.allDisplayed[0].id === service.id, | 897 | isActive: activeService ? activeService === service.id : this.allDisplayed[0].id === service.id, |
898 | })); | 898 | })); |
899 | } | 899 | } |
@@ -904,13 +904,13 @@ export default class ServicesStore extends Store { | |||
904 | const { showMessageBadgesEvenWhenMuted } = this.stores.ui; | 904 | const { showMessageBadgesEvenWhenMuted } = this.stores.ui; |
905 | 905 | ||
906 | const unreadDirectMessageCount = this.allDisplayed | 906 | const unreadDirectMessageCount = this.allDisplayed |
907 | .filter(s => (showMessageBadgeWhenMuted || s.isNotificationEnabled) && showMessageBadgesEvenWhenMuted && s.isBadgeEnabled) | 907 | .filter((s) => (showMessageBadgeWhenMuted || s.isNotificationEnabled) && showMessageBadgesEvenWhenMuted && s.isBadgeEnabled) |
908 | .map(s => s.unreadDirectMessageCount) | 908 | .map((s) => s.unreadDirectMessageCount) |
909 | .reduce((a, b) => a + b, 0); | 909 | .reduce((a, b) => a + b, 0); |
910 | 910 | ||
911 | const unreadIndirectMessageCount = this.allDisplayed | 911 | const unreadIndirectMessageCount = this.allDisplayed |
912 | .filter(s => (showMessageBadgeWhenMuted && showMessageBadgesEvenWhenMuted) && (s.isBadgeEnabled && s.isIndirectMessageBadgeEnabled)) | 912 | .filter((s) => (showMessageBadgeWhenMuted && showMessageBadgesEvenWhenMuted) && (s.isBadgeEnabled && s.isIndirectMessageBadgeEnabled)) |
913 | .map(s => s.unreadIndirectMessageCount) | 913 | .map((s) => s.unreadIndirectMessageCount) |
914 | .reduce((a, b) => a + b, 0); | 914 | .reduce((a, b) => a + b, 0); |
915 | 915 | ||
916 | // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases | 916 | // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases |
@@ -975,7 +975,7 @@ export default class ServicesStore extends Store { | |||
975 | return; | 975 | return; |
976 | } | 976 | } |
977 | 977 | ||
978 | if (this.allDisplayed.findIndex(service => service.isActive) === -1 && this.allDisplayed.length !== 0) { | 978 | if (this.allDisplayed.findIndex((service) => service.isActive) === -1 && this.allDisplayed.length !== 0) { |
979 | debug('No active service found, setting active service to index 0'); | 979 | debug('No active service found, setting active service to index 0'); |
980 | 980 | ||
981 | this._setActive({ serviceId: this.allDisplayed[0].id }); | 981 | this._setActive({ serviceId: this.allDisplayed[0].id }); |
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js index 0ca61046a..adcd776c1 100644 --- a/src/stores/UIStore.js +++ b/src/stores/UIStore.js | |||
@@ -71,7 +71,7 @@ export default class UIStore extends Store { | |||
71 | 71 | ||
72 | @computed get theme() { | 72 | @computed get theme() { |
73 | const themeId = (this.isDarkThemeActive || this.stores.settings.app.darkMode) ? 'dark' : 'default'; | 73 | const themeId = (this.isDarkThemeActive || this.stores.settings.app.darkMode) ? 'dark' : 'default'; |
74 | const accentColor = this.stores.settings.app.accentColor; | 74 | const { accentColor } = this.stores.settings.app; |
75 | return theme(themeId, accentColor); | 75 | return theme(themeId, accentColor); |
76 | } | 76 | } |
77 | 77 | ||
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 8a525c2ef..2e009893a 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -205,7 +205,7 @@ export default class UserStore extends Store { | |||
205 | } | 205 | } |
206 | 206 | ||
207 | @action async _invite({ invites }) { | 207 | @action async _invite({ invites }) { |
208 | const data = invites.filter(invite => invite.email !== ''); | 208 | const data = invites.filter((invite) => invite.email !== ''); |
209 | 209 | ||
210 | const response = await this.inviteRequest.execute(data)._promise; | 210 | const response = await this.inviteRequest.execute(data)._promise; |
211 | 211 | ||
@@ -250,7 +250,7 @@ export default class UserStore extends Store { | |||
250 | this.isImportLegacyServicesExecuting = true; | 250 | this.isImportLegacyServicesExecuting = true; |
251 | 251 | ||
252 | // Reduces recipe duplicates | 252 | // Reduces recipe duplicates |
253 | const recipes = services.filter((obj, pos, arr) => arr.map(mapObj => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map(s => s.recipe.id); | 253 | const recipes = services.filter((obj, pos, arr) => arr.map((mapObj) => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map((s) => s.recipe.id); |
254 | 254 | ||
255 | // Install recipes | 255 | // Install recipes |
256 | for (const recipe of recipes) { // eslint-disable-line no-unused-vars | 256 | for (const recipe of recipes) { // eslint-disable-line no-unused-vars |
diff --git a/src/stores/lib/CachedRequest.js b/src/stores/lib/CachedRequest.js index 31c7ce241..94f615144 100644 --- a/src/stores/lib/CachedRequest.js +++ b/src/stores/lib/CachedRequest.js | |||
@@ -92,7 +92,7 @@ export default class CachedRequest extends Request { | |||
92 | } | 92 | } |
93 | 93 | ||
94 | removeCacheForCallWith(...args) { | 94 | removeCacheForCallWith(...args) { |
95 | remove(this._apiCalls, c => isEqual(c.args, args)); | 95 | remove(this._apiCalls, (c) => isEqual(c.args, args)); |
96 | } | 96 | } |
97 | 97 | ||
98 | _addApiCall(args) { | 98 | _addApiCall(args) { |
@@ -102,6 +102,6 @@ export default class CachedRequest extends Request { | |||
102 | } | 102 | } |
103 | 103 | ||
104 | _findApiCall(args) { | 104 | _findApiCall(args) { |
105 | return this._apiCalls.find(c => isEqual(c.args, args)); | 105 | return this._apiCalls.find((c) => isEqual(c.args, args)); |
106 | } | 106 | } |
107 | } | 107 | } |
diff --git a/src/stores/lib/Reaction.js b/src/stores/lib/Reaction.js index f8009b7f6..7e1bc685e 100644 --- a/src/stores/lib/Reaction.js +++ b/src/stores/lib/Reaction.js | |||
@@ -26,6 +26,6 @@ export default class Reaction { | |||
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | export const createReactions = reactions => ( | 29 | export const createReactions = (reactions) => ( |
30 | reactions.map(r => new Reaction(r)) | 30 | reactions.map((r) => new Reaction(r)) |
31 | ); | 31 | ); |
diff --git a/src/stores/lib/Request.js b/src/stores/lib/Request.js index cfc857c2e..32ffe4367 100644 --- a/src/stores/lib/Request.js +++ b/src/stores/lib/Request.js | |||
@@ -107,7 +107,7 @@ export default class Request { | |||
107 | } | 107 | } |
108 | 108 | ||
109 | _triggerHooks() { | 109 | _triggerHooks() { |
110 | Request._hooks.forEach(hook => hook(this)); | 110 | Request._hooks.forEach((hook) => hook(this)); |
111 | } | 111 | } |
112 | 112 | ||
113 | reset = () => { | 113 | reset = () => { |
diff --git a/src/stores/lib/Store.js b/src/stores/lib/Store.js index 8d2fb4066..b03a7e725 100644 --- a/src/stores/lib/Store.js +++ b/src/stores/lib/Store.js | |||
@@ -28,18 +28,18 @@ export default class Store { | |||
28 | } | 28 | } |
29 | 29 | ||
30 | registerReactions(reactions) { | 30 | registerReactions(reactions) { |
31 | reactions.forEach(reaction => this._reactions.push(new Reaction(reaction))); | 31 | reactions.forEach((reaction) => this._reactions.push(new Reaction(reaction))); |
32 | } | 32 | } |
33 | 33 | ||
34 | setup() {} | 34 | setup() {} |
35 | 35 | ||
36 | initialize() { | 36 | initialize() { |
37 | this.setup(); | 37 | this.setup(); |
38 | this._reactions.forEach(reaction => reaction.start()); | 38 | this._reactions.forEach((reaction) => reaction.start()); |
39 | } | 39 | } |
40 | 40 | ||
41 | teardown() { | 41 | teardown() { |
42 | this._reactions.forEach(reaction => reaction.stop()); | 42 | this._reactions.forEach((reaction) => reaction.stop()); |
43 | } | 43 | } |
44 | 44 | ||
45 | resetStatus() { | 45 | resetStatus() { |