aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/ServicesStore.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/ServicesStore.ts')
-rw-r--r--src/stores/ServicesStore.ts52
1 files changed, 31 insertions, 21 deletions
diff --git a/src/stores/ServicesStore.ts b/src/stores/ServicesStore.ts
index 0ab4dbc5b..829c64d76 100644
--- a/src/stores/ServicesStore.ts
+++ b/src/stores/ServicesStore.ts
@@ -1,4 +1,4 @@
1import { shell } from 'electron'; 1import { ipcRenderer, shell } from 'electron';
2import { action, reaction, computed, observable, makeObservable } from 'mobx'; 2import { action, reaction, computed, observable, makeObservable } from 'mobx';
3import { debounce, remove } from 'lodash'; 3import { debounce, remove } from 'lodash';
4import ms from 'ms'; 4import ms from 'ms';
@@ -23,6 +23,7 @@ import { cleanseJSObject } from '../jsUtils';
23import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 23import { SPELLCHECKER_LOCALES } from '../i18n/languages';
24import { ferdiumVersion } from '../environment-remote'; 24import { ferdiumVersion } from '../environment-remote';
25import TypedStore from './lib/TypedStore'; 25import TypedStore from './lib/TypedStore';
26import type { UnreadServices } from '../lib/dbus/Ferdium';
26 27
27const debug = require('../preload-safe-debug')('Ferdium:ServiceStore'); 28const debug = require('../preload-safe-debug')('Ferdium:ServiceStore');
28 29
@@ -1230,26 +1231,29 @@ export default class ServicesStore extends TypedStore {
1230 const { showMessageBadgeWhenMuted } = this.stores.settings.all.app; 1231 const { showMessageBadgeWhenMuted } = this.stores.settings.all.app;
1231 const { showMessageBadgesEvenWhenMuted } = this.stores.ui; 1232 const { showMessageBadgesEvenWhenMuted } = this.stores.ui;
1232 1233
1233 const unreadDirectMessageCount = this.allDisplayed 1234 const unreadServices: UnreadServices = [];
1234 .filter( 1235 let unreadDirectMessageCount = 0;
1235 s => 1236 let unreadIndirectMessageCount = 0;
1236 (showMessageBadgeWhenMuted || s.isNotificationEnabled) && 1237
1237 showMessageBadgesEvenWhenMuted && 1238 if (showMessageBadgesEvenWhenMuted) {
1238 s.isBadgeEnabled, 1239 for (const s of this.allDisplayed) {
1239 ) 1240 if (s.isBadgeEnabled) {
1240 .map(s => s.unreadDirectMessageCount) 1241 const direct =
1241 .reduce((a, b) => a + b, 0); 1242 showMessageBadgeWhenMuted || s.isNotificationEnabled
1242 1243 ? s.unreadDirectMessageCount
1243 const unreadIndirectMessageCount = this.allDisplayed 1244 : 0;
1244 .filter( 1245 const indirect =
1245 s => 1246 showMessageBadgeWhenMuted && s.isIndirectMessageBadgeEnabled
1246 showMessageBadgeWhenMuted && 1247 ? s.unreadIndirectMessageCount
1247 showMessageBadgesEvenWhenMuted && 1248 : 0;
1248 s.isBadgeEnabled && 1249 unreadDirectMessageCount += direct;
1249 s.isIndirectMessageBadgeEnabled, 1250 unreadIndirectMessageCount += indirect;
1250 ) 1251 if (direct > 0 || indirect > 0) {
1251 .map(s => s.unreadIndirectMessageCount) 1252 unreadServices.push([s.name, direct, indirect]);
1252 .reduce((a, b) => a + b, 0); 1253 }
1254 }
1255 }
1256 }
1253 1257
1254 // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases 1258 // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases
1255 if (showMessageBadgesEvenWhenMuted) { 1259 if (showMessageBadgesEvenWhenMuted) {
@@ -1257,6 +1261,12 @@ export default class ServicesStore extends TypedStore {
1257 unreadDirectMessageCount, 1261 unreadDirectMessageCount,
1258 unreadIndirectMessageCount, 1262 unreadIndirectMessageCount,
1259 }); 1263 });
1264 ipcRenderer.send(
1265 'updateDBusUnread',
1266 unreadDirectMessageCount,
1267 unreadIndirectMessageCount,
1268 unreadServices,
1269 );
1260 } 1270 }
1261 } 1271 }
1262 1272