Skip to content

Commit

Permalink
Ignore notification close event
Browse files Browse the repository at this point in the history
fixes #4002
  • Loading branch information
nicodh committed Jul 5, 2024
1 parent 2c99028 commit c197083
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ function showNotification(_event: IpcMainInvokeEvent, data: DcNotification) {
notify.close()
})
notify.on('close', () => {
notifications[chatId] =
notifications[chatId]?.filter(n => n !== notify) || []
// this is triggered when the message is moved to notification center
// so we don't remove the instance from the list
})

if (notifications[chatId]) {
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/backend-com.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export namespace EffectfulBackendActions {
await BackendRemote.rpc.deleteChat(accountId, chatId)
clearNotificationsForChat(accountId, chatId)
}

export async function marknoticedChat(accountId: number, chatId: number) {
await BackendRemote.rpc.marknoticedChat(accountId, chatId)
clearNotificationsForChat(accountId, chatId)
}
}

type ContextEvents = { ALL: (event: DcEvent) => void } & {
Expand Down
14 changes: 8 additions & 6 deletions src/renderer/components/AccountListSidebar/AccountItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React, { useEffect, useState } from 'react'
import classNames from 'classnames'
import debounce from 'debounce'

import { BackendRemote, onDCEvent } from '../../backend-com'
import {
BackendRemote,
onDCEvent,
EffectfulBackendActions,
} from '../../backend-com'
import { avatarInitial } from '../Avatar'
import { getLogger } from '../../../shared/logger'
import useTranslationFunction from '../../hooks/useTranslationFunction'
Expand Down Expand Up @@ -201,9 +205,7 @@ async function markAccountAsRead(accountId: number) {
}
}

await Promise.all(
[...uniqueChatIds].map(chatId =>
BackendRemote.rpc.marknoticedChat(accountId, chatId)
)
)
for (const chatId of uniqueChatIds) {
await EffectfulBackendActions.marknoticedChat(accountId, chatId)
}
}
4 changes: 2 additions & 2 deletions src/renderer/components/chat/ChatListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { T, C } from '@deltachat/jsonrpc-client'

import Timestamp from '../conversations/Timestamp'
import { Avatar } from '../Avatar'
import { BackendRemote, Type } from '../../backend-com'
import { BackendRemote, Type, EffectfulBackendActions } from '../../backend-com'

Check failure on line 7 in src/renderer/components/chat/ChatListItem.tsx

View workflow job for this annotation

GitHub Actions / Code Validation

'BackendRemote' is defined but never used. Allowed unused vars must match /^_/u
import { mapCoreMsgStatus2String } from '../helpers/MapMsgStatus'
import { getLogger } from '../../../shared/logger'
import { useContextMenuWithActiveState } from '../ContextMenu'
Expand Down Expand Up @@ -150,7 +150,7 @@ function ChatListItemArchiveLink({
{
label: tx('mark_all_as_read'),
action: () => {
BackendRemote.rpc.marknoticedChat(
EffectfulBackendActions.marknoticedChat(
selectedAccountId(),
C.DC_CHAT_ID_ARCHIVED_LINK
)
Expand Down

0 comments on commit c197083

Please sign in to comment.