Handle last read sent message better, might address #301

This commit is contained in:
Sebastian Wolf 2021-02-02 23:19:02 +01:00
parent 3176c3dc8c
commit 978ee5a334
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
2 changed files with 12 additions and 6 deletions

View file

@ -145,7 +145,7 @@ Page {
function initializePage() {
Debug.log("[ChatPage] Initializing chat page...");
chatView.currentIndex = -1;
chatView.lastReadSentIndex = 0;
chatView.lastReadSentIndex = -1;
var chatType = chatInformation.type['@type'];
isPrivateChat = chatType === "chatTypePrivate";
isSecretChat = chatType === "chatTypeSecret";
@ -182,6 +182,7 @@ Page {
}
function getMessageStatusText(message, listItemIndex, lastReadSentIndex, useElapsed) {
Debug.log("Last read sent index: " + lastReadSentIndex);
var messageStatusSuffix = "";
if(!message) {
return "";
@ -597,6 +598,10 @@ Page {
if (!chatPage.isInitialized) {
chatView.scrollToIndex(modelIndex);
}
if (chatView.height > chatView.contentHeight) {
Debug.log("[ChatPage] Chat content quite small...");
viewMessageTimer.queueViewMessage(chatView.count - 1);
}
chatViewCooldownTimer.restart();
}
onNotificationSettingsUpdated: {
@ -800,7 +805,7 @@ Page {
Rectangle {
id: chatSecretBackground
color: Theme.highlightBackgroundColor
color: Theme.rgba(Theme.overlayBackgroundColor, Theme.opacityFaint)
width: chatPage.isPortrait ? Theme.fontSizeLarge : Theme.fontSizeMedium
height: width
anchors.left: parent.left
@ -960,7 +965,7 @@ Page {
clip: true
highlightMoveDuration: 0
highlightResizeDuration: 0
property int lastReadSentIndex: 0
property int lastReadSentIndex: -1
property bool inCooldown: false
property bool manuallyScrolledToBottom
property QtObject precalculatedValues: QtObject {

View file

@ -757,12 +757,12 @@ int ChatModel::calculateLastKnownMessageId()
LOG("contains last read ID?" << messageIndexMap.contains(lastKnownMessageId));
LOG("contains last own ID?" << messageIndexMap.contains(lastOwnMessageId));
int listInboxPosition = messageIndexMap.value(lastKnownMessageId, messages.size() - 1);
int listOwnPosition = messageIndexMap.value(lastOwnMessageId, 0);
int listOwnPosition = messageIndexMap.value(lastOwnMessageId, -1);
if (listInboxPosition > this->messages.size() - 1 ) {
listInboxPosition = this->messages.size() - 1;
}
if (listOwnPosition > this->messages.size() - 1 ) {
listOwnPosition = 0;
listOwnPosition = -1;
}
LOG("Last known message is at position" << listInboxPosition);
LOG("Last own message is at position" << listOwnPosition);
@ -776,8 +776,9 @@ int ChatModel::calculateLastReadSentMessageId()
LOG("lastReadSentMessageId" << lastReadSentMessageId);
LOG("size messageIndexMap" << messageIndexMap.size());
LOG("contains ID?" << messageIndexMap.contains(lastReadSentMessageId));
const int listOutboxPosition = messageIndexMap.value(lastReadSentMessageId, messages.size() - 1);
const int listOutboxPosition = messageIndexMap.value(lastReadSentMessageId, -1);
LOG("Last read sent message is at position" << listOutboxPosition);
emit lastReadSentMessageUpdated(listOutboxPosition);
return listOutboxPosition;
}