Disable some stuff that is not needed in search mode
This commit is contained in:
parent
225eb76899
commit
72fd008dfc
3 changed files with 16 additions and 12 deletions
|
@ -480,7 +480,7 @@ Page {
|
||||||
chatView.lastReadSentIndex = lastReadSentIndex;
|
chatView.lastReadSentIndex = lastReadSentIndex;
|
||||||
chatView.scrollToIndex(modelIndex);
|
chatView.scrollToIndex(modelIndex);
|
||||||
chatPage.loading = false;
|
chatPage.loading = false;
|
||||||
if (modelIndex >= (chatView.count - 10)) {
|
if (chatOverviewItem.visible && modelIndex >= (chatView.count - 10)) {
|
||||||
chatView.inCooldown = true;
|
chatView.inCooldown = true;
|
||||||
chatModel.triggerLoadMoreFuture();
|
chatModel.triggerLoadMoreFuture();
|
||||||
}
|
}
|
||||||
|
@ -489,6 +489,8 @@ Page {
|
||||||
Debug.log("[ChatPage] Chat content quite small...");
|
Debug.log("[ChatPage] Chat content quite small...");
|
||||||
viewMessageTimer.queueViewMessage(chatView.count - 1);
|
viewMessageTimer.queueViewMessage(chatView.count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chatViewCooldownTimer.restart();
|
||||||
}
|
}
|
||||||
onNewMessageReceived: {
|
onNewMessageReceived: {
|
||||||
if (chatView.manuallyScrolledToBottom || message.sender.user_id === chatPage.myUserId) {
|
if (chatView.manuallyScrolledToBottom || message.sender.user_id === chatPage.myUserId) {
|
||||||
|
@ -499,7 +501,7 @@ Page {
|
||||||
onUnreadCountUpdated: {
|
onUnreadCountUpdated: {
|
||||||
Debug.log("[ChatPage] Unread count updated, new count: ", unreadCount);
|
Debug.log("[ChatPage] Unread count updated, new count: ", unreadCount);
|
||||||
chatInformation.unread_count = unreadCount;
|
chatInformation.unread_count = unreadCount;
|
||||||
chatUnreadMessagesCountBackground.visible = ( !chatPage.loading && unreadCount > 0 );
|
chatUnreadMessagesItem.visible = ( !chatPage.loading && chatInformation.unread_count > 0 && chatOverviewItem.visible );
|
||||||
chatUnreadMessagesCount.text = unreadCount > 99 ? "99+" : unreadCount;
|
chatUnreadMessagesCount.text = unreadCount > 99 ? "99+" : unreadCount;
|
||||||
}
|
}
|
||||||
onLastReadSentMessageUpdated: {
|
onLastReadSentMessageUpdated: {
|
||||||
|
@ -509,7 +511,7 @@ Page {
|
||||||
onMessagesIncrementalUpdate: {
|
onMessagesIncrementalUpdate: {
|
||||||
Debug.log("Incremental update received. View now has ", chatView.count, " messages, view is on index ", modelIndex, ", own messages were read before index ", lastReadSentIndex);
|
Debug.log("Incremental update received. View now has ", chatView.count, " messages, view is on index ", modelIndex, ", own messages were read before index ", lastReadSentIndex);
|
||||||
chatView.lastReadSentIndex = lastReadSentIndex;
|
chatView.lastReadSentIndex = lastReadSentIndex;
|
||||||
chatViewCooldownTimer.start();
|
chatViewCooldownTimer.restart();
|
||||||
}
|
}
|
||||||
onNotificationSettingsUpdated: {
|
onNotificationSettingsUpdated: {
|
||||||
chatInformation = chatModel.getChatInformation();
|
chatInformation = chatModel.getChatInformation();
|
||||||
|
@ -649,7 +651,7 @@ Page {
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
id: searchInChatMenuItem
|
id: searchInChatMenuItem
|
||||||
visible: !chatPage.isSecretChat
|
visible: !chatPage.isSecretChat && chatOverviewItem.visible
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// This automatically shows the search field as well
|
// This automatically shows the search field as well
|
||||||
chatOverviewItem.visible = false;
|
chatOverviewItem.visible = false;
|
||||||
|
@ -773,7 +775,7 @@ Page {
|
||||||
width: parent.width - chatPictureThumbnail.width - Theme.paddingMedium
|
width: parent.width - chatPictureThumbnail.width - Theme.paddingMedium
|
||||||
height: searchInChatField.height
|
height: searchInChatField.height
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: chatPage.isPortrait ? Theme.paddingMedium : Theme.paddingSmall
|
anchors.bottomMargin: chatPage.isPortrait ? Theme.paddingSmall : 0
|
||||||
|
|
||||||
SearchField {
|
SearchField {
|
||||||
id: searchInChatField
|
id: searchInChatField
|
||||||
|
@ -885,7 +887,7 @@ Page {
|
||||||
|
|
||||||
function handleScrollPositionChanged() {
|
function handleScrollPositionChanged() {
|
||||||
Debug.log("Current position: ", chatView.contentY);
|
Debug.log("Current position: ", chatView.contentY);
|
||||||
if (chatInformation.unread_count > 0) {
|
if (chatOverviewItem.visible && chatInformation.unread_count > 0) {
|
||||||
var bottomIndex = chatView.indexAt(chatView.contentX, ( chatView.contentY + chatView.height - Theme.horizontalPageMargin ));
|
var bottomIndex = chatView.indexAt(chatView.contentX, ( chatView.contentY + chatView.height - Theme.horizontalPageMargin ));
|
||||||
if (bottomIndex > -1) {
|
if (bottomIndex > -1) {
|
||||||
viewMessageTimer.queueViewMessage(bottomIndex)
|
viewMessageTimer.queueViewMessage(bottomIndex)
|
||||||
|
@ -905,12 +907,13 @@ Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
onContentYChanged: {
|
onContentYChanged: {
|
||||||
|
Debug.log("In Cooldown: " + chatView.inCooldown);
|
||||||
if (!chatPage.loading && !chatView.inCooldown) {
|
if (!chatPage.loading && !chatView.inCooldown) {
|
||||||
if (chatView.indexAt(chatView.contentX, chatView.contentY) < 10) {
|
if (chatView.indexAt(chatView.contentX, chatView.contentY) < 10) {
|
||||||
Debug.log("[ChatPage] Trying to get older history items...");
|
Debug.log("[ChatPage] Trying to get older history items...");
|
||||||
chatView.inCooldown = true;
|
chatView.inCooldown = true;
|
||||||
chatModel.triggerLoadMoreHistory();
|
chatModel.triggerLoadMoreHistory();
|
||||||
} else if (chatView.indexAt(chatView.contentX, chatView.contentY) > ( count - 10)) {
|
} else if (chatOverviewItem.visible && chatView.indexAt(chatView.contentX, chatView.contentY) > ( count - 10)) {
|
||||||
Debug.log("[ChatPage] Trying to get newer history items...");
|
Debug.log("[ChatPage] Trying to get newer history items...");
|
||||||
chatView.inCooldown = true;
|
chatView.inCooldown = true;
|
||||||
chatModel.triggerLoadMoreFuture();
|
chatModel.triggerLoadMoreFuture();
|
||||||
|
@ -1046,12 +1049,13 @@ Page {
|
||||||
anchors.rightMargin: Theme.paddingMedium
|
anchors.rightMargin: Theme.paddingMedium
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: Theme.paddingMedium
|
anchors.bottomMargin: Theme.paddingMedium
|
||||||
|
visible: !chatPage.loading && chatInformation.unread_count > 0 && chatOverviewItem.visible
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: chatUnreadMessagesCountBackground
|
id: chatUnreadMessagesCountBackground
|
||||||
color: Theme.highlightBackgroundColor
|
color: Theme.highlightBackgroundColor
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: width / 2
|
radius: width / 2
|
||||||
visible: !chatPage.loading && chatInformation.unread_count > 0
|
visible: chatUnreadMessagesItem.visible
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
@ -1060,7 +1064,7 @@ Page {
|
||||||
font.bold: true
|
font.bold: true
|
||||||
color: Theme.primaryColor
|
color: Theme.primaryColor
|
||||||
anchors.centerIn: chatUnreadMessagesCountBackground
|
anchors.centerIn: chatUnreadMessagesCountBackground
|
||||||
visible: chatUnreadMessagesCountBackground.visible
|
visible: chatUnreadMessagesItem.visible
|
||||||
text: chatInformation.unread_count > 99 ? "99+" : chatInformation.unread_count
|
text: chatInformation.unread_count > 99 ? "99+" : chatInformation.unread_count
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
|
@ -353,7 +353,7 @@ void ChatModel::handleNewMessageReceived(qlonglong chatId, const QVariantMap &me
|
||||||
{
|
{
|
||||||
const qlonglong messageId = message.value(ID).toLongLong();
|
const qlonglong messageId = message.value(ID).toLongLong();
|
||||||
if (chatId == this->chatId && !messageIndexMap.contains(messageId)) {
|
if (chatId == this->chatId && !messageIndexMap.contains(messageId)) {
|
||||||
if (this->isMostRecentMessageLoaded()) {
|
if (this->isMostRecentMessageLoaded() && !this->searchModeActive) {
|
||||||
LOG("New message received for this chat");
|
LOG("New message received for this chat");
|
||||||
QList<MessageData*> messagesToBeAdded;
|
QList<MessageData*> messagesToBeAdded;
|
||||||
messagesToBeAdded.append(new MessageData(message, messageId));
|
messagesToBeAdded.append(new MessageData(message, messageId));
|
||||||
|
|
|
@ -939,14 +939,14 @@ void TDLibWrapper::importContacts(const QVariantList &contacts)
|
||||||
|
|
||||||
void TDLibWrapper::searchChatMessages(const qlonglong &chatId, const QString &query, const qlonglong fromMessageId)
|
void TDLibWrapper::searchChatMessages(const qlonglong &chatId, const QString &query, const qlonglong fromMessageId)
|
||||||
{
|
{
|
||||||
LOG("Searching for messages" << chatId << query);
|
LOG("Searching for messages" << chatId << query << fromMessageId);
|
||||||
QVariantMap requestObject;
|
QVariantMap requestObject;
|
||||||
requestObject.insert(_TYPE, "searchChatMessages");
|
requestObject.insert(_TYPE, "searchChatMessages");
|
||||||
requestObject.insert("chat_id", chatId);
|
requestObject.insert("chat_id", chatId);
|
||||||
requestObject.insert("query", query);
|
requestObject.insert("query", query);
|
||||||
requestObject.insert("from_message_id", fromMessageId);
|
requestObject.insert("from_message_id", fromMessageId);
|
||||||
requestObject.insert("offset", 0);
|
requestObject.insert("offset", 0);
|
||||||
requestObject.insert("limit", 100);
|
requestObject.insert("limit", 50);
|
||||||
requestObject.insert(_EXTRA, "searchChatMessages");
|
requestObject.insert(_EXTRA, "searchChatMessages");
|
||||||
this->sendRequest(requestObject);
|
this->sendRequest(requestObject);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue