fix(@chat): react to on clear history

fixes #4527
This commit is contained in:
Anthony Laibe 2022-01-25 11:08:58 +01:00 committed by Sale Djenic
parent f4ed7f09cd
commit cfd227f9f2
4 changed files with 17 additions and 1 deletions

View File

@ -115,6 +115,12 @@ method init*(self: Controller) =
return
self.delegate.onMessageEdited(args.message)
self.events.on(SIGNAL_CHAT_HISTORY_CLEARED) do (e: Args):
var args = ChatArgs(e)
if(self.chatId != args.chatId):
return
self.delegate.onHistoryCleared()
method getMySectionId*(self: Controller): string =
return self.sectionId

View File

@ -281,6 +281,9 @@ method onMessageEdited*(self: Module, message: MessageDto) =
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
self.view.model().updateEditedMsg(message.id, renderedMessageText, message.containsContactMentions())
method onHistoryCleared*(self: Module) =
self.view.model().clear()
method updateChatIdentifier*(self: Module) =
# Delete the old ChatIdentifier message first
self.view.model().removeItem(CHAT_IDENTIFIER_MESSAGE_ID)

View File

@ -30,3 +30,6 @@ method onMessageDeleted*(self: AccessInterface, messageId: string) {.base.} =
method editMessage*(self: AccessInterface, messageId: string, updatedMsg: string) {.base.} =
raise newException(ValueError, "No implementation available")
method onHistoryCleared*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -350,4 +350,8 @@ QtObject:
let index = self.createIndex(ind, 0, nil)
self.dataChanged(index, index, @[ModelRole.MessageText.int, ModelRole.MessageContainsMentions.int, ModelRole.IsEdited.int])
proc clear*(self: Model) =
self.beginResetModel()
self.items = @[]
self.endResetModel()
self.countChanged()