Merge remote-tracking branch 'handydevcom/Fix_Scroll_To_Quoted_Message' into aurora_beta
This commit is contained in:
commit
25ce179a31
3 changed files with 15 additions and 4 deletions
|
@ -417,7 +417,7 @@ Page {
|
|||
chatPage.messageIdToScrollTo = messageId
|
||||
}
|
||||
if (chatPage.messageIdToScrollTo && chatPage.messageIdToScrollTo != "") {
|
||||
var index = chatModel.getMessageIndex(chatPage.messageIdToScrollTo);
|
||||
var index = chatModel.getDisplayedMessageIndex(chatPage.messageIdToScrollTo);
|
||||
if(index !== -1) {
|
||||
chatPage.messageIdToScrollTo = "";
|
||||
chatView.scrollToIndex(index);
|
||||
|
|
|
@ -472,13 +472,24 @@ QVariantMap ChatModel::getMessage(int index)
|
|||
return QVariantMap();
|
||||
}
|
||||
|
||||
int ChatModel::getMessageIndex(qlonglong messageId)
|
||||
int ChatModel::getDisplayedMessageIndex(qlonglong messageId)
|
||||
{
|
||||
if (messages.size() == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (messageIndexMap.contains(messageId)) {
|
||||
return messageIndexMap.value(messageId);
|
||||
int rawIndex = messageIndexMap.value(messageId);
|
||||
// We need to substract number of albums which are shown before this item, because that's the index it's displayed on screen at.
|
||||
int realIndex = rawIndex;
|
||||
for(int i = 0; i < rawIndex; i++) {
|
||||
MessageData *message = messages.at(i);
|
||||
if(message->albumMessageIds.count() > 0) {
|
||||
realIndex -= (message->albumMessageIds.count() - 1);
|
||||
}
|
||||
}
|
||||
if(realIndex < -1)
|
||||
return -1;
|
||||
return realIndex;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
Q_INVOKABLE int getLastReadMessageIndex();
|
||||
Q_INVOKABLE void setSearchQuery(const QString newSearchQuery);
|
||||
|
||||
Q_INVOKABLE int getMessageIndex(qlonglong messageId);
|
||||
Q_INVOKABLE int getDisplayedMessageIndex(qlonglong messageId);
|
||||
QVariantMap smallPhoto() const;
|
||||
qlonglong getChatId() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue