fix(Timeline): ensure messagesList QtProperty is notified for rendering

The `messageList` model used for rendering messages gets notified by the
`activeChannelChanged()` signal. That signal is not immediately emitted inside
the timeline when new messages are received.

This causes the underlying view data to be out of sync with the model,
causing UI bugs, such as rendering the `EmptyTimeline` component when in fact,
the timeline is not empty.

To fix this, there are two options:

1. Change the signal from `activeChannelChanged` to `messagePushed` signal, which
is for sure emitted when messages are received
2. Ensure `activeChannelChanged` is emitted when messages are pushed and the
active channel is indeed the timeline

Since the application has been relying on `activeChannelChanged` so far, I decided
to go with option 2 as I'm not sure whether option 1 would introduce other unwanted
side effects.
This commit is contained in:
Pascal Precht 2021-01-07 11:36:39 +01:00 committed by Iuri Matias
parent 0a96b76b9c
commit b0cd49b111
1 changed files with 3 additions and 1 deletions

View File

@ -308,7 +308,9 @@ QtObject:
if self.status.chat.channels.hasKey(msg.chatId): if self.status.chat.channels.hasKey(msg.chatId):
let chat = self.status.chat.channels[msg.chatId] let chat = self.status.chat.channels[msg.chatId]
if (chat.chatType == ChatType.Profile): if (chat.chatType == ChatType.Profile):
self.messageList[status_utils.getTimelineChatId()].add(msg) let timelineChatId = status_utils.getTimelineChatId()
self.messageList[timelineChatId].add(msg)
if self.activeChannel.id == timelineChatId: self.activeChannelChanged()
else: else:
self.messageList[msg.chatId].add(msg) self.messageList[msg.chatId].add(msg)
self.messagePushed() self.messagePushed()