refactor(@chat): clear chat history

This commit is contained in:
Anthony Laibe 2021-12-08 14:06:31 +01:00 committed by Sale Djenic
parent 8ddda242d8
commit 6c76974985
8 changed files with 42 additions and 4 deletions

View File

@ -134,4 +134,7 @@ method unmuteChat*(self: Controller, chatId: string) =
self.chatService.unmuteChat(chatId)
method markAllMessagesRead*(self: Controller, chatId: string) =
self.messageService.markAllMessagesRead(chatId)
self.messageService.markAllMessagesRead(chatId)
method clearChatHistory*(self: Controller, chatId: string) =
self.chatService.clearChatHistory(chatId)

View File

@ -61,4 +61,7 @@ method unmuteChat*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")
method markAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")
method clearChatHistory*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -295,4 +295,7 @@ method onMarkAllMessagesRead*(self: Module, chatId: string) =
self.view.model().setHasUnreadMessage(chatId, value=false)
method markAllMessagesRead*(self: Module, chatId: string) =
self.controller.markAllMessagesRead(chatId)
self.controller.markAllMessagesRead(chatId)
method clearChatHistory*(self: Module, chatId: string) =
self.controller.clearChatHistory(chatId)

View File

@ -34,4 +34,7 @@ method unmuteChat*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")
method markAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")
method clearChatHistory*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -106,4 +106,7 @@ QtObject:
self.delegate.unmuteChat(chatId)
proc markAllMessagesRead*(self: View, chatId: string) {.slot.} =
self.delegate.markAllMessagesRead(chatId)
self.delegate.markAllMessagesRead(chatId)
proc clearChatHistory*(self: View, chatId: string) {.slot.} =
self.delegate.clearChatHistory(chatId)

View File

@ -58,6 +58,7 @@ const SIGNAL_SENDING_SUCCESS* = "messageSendingSuccess_new"
const SIGNAL_MESSAGE_DELETED* = "messageDeleted_new"
const SIGNAL_CHAT_MUTED* = "new-chatMuted"
const SIGNAL_CHAT_UNMUTED* = "new-chatUnmuted"
const SIGNAL_CHAT_HISTORY_CLEARED* = "new-chatHistoryCleared"
QtObject:
type Service* = ref object of QObject
@ -320,4 +321,18 @@ QtObject:
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
return
return
method clearChatHistory*(self: Service, chatId: string) =
try:
let response = status_chat.deleteMessagesByChatId(chatId)
if(not response.error.isNil):
let msg = response.error.message & " chatId=" & chatId
error "error while clearing chat history ", msg
return
self.events.emit(SIGNAL_CHAT_HISTORY_CLEARED, ChatArgs(chatId: chatId))
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
return

View File

@ -288,6 +288,10 @@ Item {
onMarkAllMessagesRead: {
root.communitySectionModule.markAllMessagesRead(id)
}
onClearChatHistory: {
root.communitySectionModule.clearChatHistory(id)
}
}
}

View File

@ -287,6 +287,10 @@ Item {
onMarkAllMessagesRead: {
root.chatSectionModule.markAllMessagesRead(id)
}
onClearChatHistory: {
root.chatSectionModule.clearChatHistory(id)
}
}
}