Fix crash when forwarding to some chats, introduce iterative init
This commit is contained in:
parent
6e6396eac4
commit
9141b8e68b
2 changed files with 12 additions and 6 deletions
|
@ -42,6 +42,7 @@ Page {
|
||||||
property var chatGroupInformation;
|
property var chatGroupInformation;
|
||||||
property int chatOnlineMemberCount: 0;
|
property int chatOnlineMemberCount: 0;
|
||||||
property var emojiProposals;
|
property var emojiProposals;
|
||||||
|
property bool iterativeInitialization: false;
|
||||||
readonly property bool userIsMember: (isPrivateChat && chatInformation["@type"]) || // should be optimized
|
readonly property bool userIsMember: (isPrivateChat && chatInformation["@type"]) || // should be optimized
|
||||||
(isBasicGroup || isSuperGroup) && (
|
(isBasicGroup || isSuperGroup) && (
|
||||||
(chatGroupInformation.status["@type"] === "chatMemberStatusMember")
|
(chatGroupInformation.status["@type"] === "chatMemberStatusMember")
|
||||||
|
@ -350,10 +351,15 @@ Page {
|
||||||
onMessagesReceived: {
|
onMessagesReceived: {
|
||||||
console.log("[ChatPage] Messages received, view has " + chatView.count + " messages, setting view to index " + modelIndex + ", own messages were read before index " + lastReadSentIndex);
|
console.log("[ChatPage] Messages received, view has " + chatView.count + " messages, setting view to index " + modelIndex + ", own messages were read before index " + lastReadSentIndex);
|
||||||
if (totalCount === 0) {
|
if (totalCount === 0) {
|
||||||
|
if (chatPage.iterativeInitialization) {
|
||||||
|
chatPage.iterativeInitialization = false;
|
||||||
console.log("[ChatPage] actually, skipping that: No Messages in Chat.");
|
console.log("[ChatPage] actually, skipping that: No Messages in Chat.");
|
||||||
chatView.positionViewAtEnd();
|
chatView.positionViewAtEnd();
|
||||||
chatPage.loading = false;
|
chatPage.loading = false;
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
chatPage.iterativeInitialization = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
chatView.lastReadSentIndex = lastReadSentIndex;
|
chatView.lastReadSentIndex = lastReadSentIndex;
|
||||||
|
|
|
@ -197,7 +197,7 @@ void ChatModel::handleMessagesReceived(const QVariantList &messages, int totalCo
|
||||||
this->messagesMutex.unlock();
|
this->messagesMutex.unlock();
|
||||||
|
|
||||||
// First call only returns a few messages, we need to get a little more than that...
|
// First call only returns a few messages, we need to get a little more than that...
|
||||||
if ((this->messagesToBeAdded.size() + this->messages.size()) < 10 && !this->inReload) {
|
if (!this->messagesToBeAdded.isEmpty() && (this->messagesToBeAdded.size() + this->messages.size()) < 10 && !this->inReload) {
|
||||||
LOG("Only a few messages received in first call, loading more...");
|
LOG("Only a few messages received in first call, loading more...");
|
||||||
this->inReload = true;
|
this->inReload = true;
|
||||||
this->tdLibWrapper->getChatHistory(this->chatId, this->messagesToBeAdded.first().toMap().value(ID).toLongLong());
|
this->tdLibWrapper->getChatHistory(this->chatId, this->messagesToBeAdded.first().toMap().value(ID).toLongLong());
|
||||||
|
|
Loading…
Reference in a new issue