Browse Source

FIX | Delete selected messages from local db after they have been soft deleted (#36)

BANK-1144: GROUP. Масові дії з повідомленнями
Co-authored-by: Vitalik Yatsenko <vitalik@noreply.localhost>
Reviewed-on: #36
Co-authored-by: Oksana Stepanenko <oksana.stepanenko@jetup.team>
Co-committed-by: Oksana Stepanenko <oksana.stepanenko@jetup.team>
pull/37/head
Oksana Stepanenko 8 months ago committed by Vitalik Yatsenko
parent
commit
ad65e93ecb
  1. 2
      src/managers/chat-message.manager.ts
  2. 2
      src/modules/chats/hooks/use-chat-messages.hook.ts
  3. 6
      src/shared/events/index.ts

2
src/managers/chat-message.manager.ts

@ -539,6 +539,7 @@ export class ChatMessageManager extends Manager { @@ -539,6 +539,7 @@ export class ChatMessageManager extends Manager {
const dbMessage = await this.dbCMRepository.getMessage(
data.messageId.toString(),
)
if (!dbMessage) return
const dbChat = await this.dbChatRepository.fetchChatDetails(
@ -632,6 +633,7 @@ export class ChatMessageManager extends Manager { @@ -632,6 +633,7 @@ export class ChatMessageManager extends Manager {
appEvents.emit('onDeleteMessage', {
chatId: message.chatId,
messageId: message.id,
isOfflineMessage: true,
})
}

2
src/modules/chats/hooks/use-chat-messages.hook.ts

@ -558,7 +558,7 @@ export const useChatMessages = ( @@ -558,7 +558,7 @@ export const useChatMessages = (
useEventsListener(
'onDeleteMessage',
data => onMessageDeleted(data, false),
data => onMessageDeleted(data, data.isOfflineMessage),
[chatId, messages],
)

6
src/shared/events/index.ts

@ -105,7 +105,11 @@ export type AppEvents = { @@ -105,7 +105,11 @@ export type AppEvents = {
}
onClearAllChats: {}
onDeleteAllChats: {}
onDeleteMessage: { chatId: number | string; messageId: number | string }
onDeleteMessage: {
chatId: number | string
messageId: number | string
isOfflineMessage?: boolean
}
onChangeMemberRole: { memberId: number | string; role: ChatMemberRole }
onDeleteMember: { memberId: number | string }
openRecordVoiceModal: RecordAudioModalSettings

Loading…
Cancel
Save