Skip to content

Commit 5aee265

Browse files
committed
rework to using new UNREAD_COUNT_UPDATED events from spreed
Signed-off-by: Markus Stoll <[email protected]>
1 parent 388161f commit 5aee265

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/talk/renderer/TalkWrapper/TalkWrapper.vue

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { onTalkHashDirty, onTalkHashUpdate, openConversation, setTalkHash } from
99
import { registerTalkDesktopSettingsSection } from '../Settings/index.ts'
1010
import { subscribeBroadcast } from '../../../shared/broadcast.service.ts'
1111
import { appData } from '../../../app/AppData.js'
12+
import { subscribe } from '@nextcloud/event-bus'
13+
import { EVENTS } from '@talk/src/constants.ts'
1214

1315
const emit = defineEmits<{
1416
(event: 'ready'): void
@@ -34,6 +36,16 @@ onMounted(async () => {
3436
appData.setTalkHashDirty(true).persist()
3537
})
3638

39+
subscribe(EVENTS.UNREAD_COUNT_UPDATED, (eventData) => {
40+
// Process unread counter values
41+
const { totalUnreadMessages, totalUnreadMentions, totalUnreadMentionsDirect } = eventData
42+
43+
if (window.TALK_DESKTOP) {
44+
const badgeCount = totalUnreadMessages
45+
window.TALK_DESKTOP.setBadgeCount(badgeCount)
46+
}
47+
})
48+
3749
// Ready
3850
emit('ready')
3951
})

src/talk/renderer/notifications/notifications.store.js

-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export function createNotificationStore() {
9494
if (notifications.length > _oldcount) {
9595
_oldcount = notifications.length
9696
if (state.backgroundFetching && document.hidden) {
97-
window.TALK_DESKTOP.setBadgeCount()
9897
window.TALK_DESKTOP.flashAppIcon(true)
9998
// If we didn't already highlight, store the title so we can restore on tab-view
10099
if (!document.title.startsWith('* ')) {
@@ -110,7 +109,6 @@ export function createNotificationStore() {
110109
* the Talk might have altered it.
111110
*/
112111
function _restoreTitle() {
113-
window.TALK_DESKTOP.setBadgeCount(0)
114112
window.TALK_DESKTOP.flashAppIcon(false)
115113
if (document.title.startsWith('* ')) {
116114
document.title = document.title.substring(2)

0 commit comments

Comments
 (0)