From 670960e18a7e9a1d994f26af27a12c73a7413c9a Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 16 May 2021 14:55:17 +0300 Subject: Do not open special chats from the chatlist Archive chat and contact request chatlist items should be treated differently. While they are not implemented, selecting them is a no-op. --- qml/ChatlistPage.qml | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/qml/ChatlistPage.qml b/qml/ChatlistPage.qml index 31c74a2..71e4bbf 100644 --- a/qml/ChatlistPage.qml +++ b/qml/ChatlistPage.qml @@ -101,24 +101,35 @@ Kirigami.ScrollablePage { model: chatlistModel onCurrentItemChanged: { - var chatId = chatlistModel.get(currentIndex).chatId - chatlistPage.context.marknoticedChat(chatId) - - console.log("Current index is " + currentIndex) - console.log("Selected chat " + chatId) - - console.log("Depth is " + pageStack.depth) - let chatPageComponent = Qt.createComponent("qrc:/qml/ChatPage.qml") - if (chatPageComponent.status == Component.Ready) { - let myPage = chatPageComponent.createObject(chatlistPage, {chatId: chatId, context: chatlistPage.context, eventEmitter: chatlistPage.eventEmitter}) - if (pageStack.depth == 1) { - pageStack.push(myPage) - } else if (pageStack.depth == 2) { - pageStack.currentIndex = 1 - pageStack.replace(myPage) + console.log("Current index is " + chatlist.currentIndex) + if (currentIndex == -1) { + return; + } + + var chatId = chatlistModel.get(chatlist.currentIndex).chatId + + if (chatId > 9) { + // > DC_CHAT_ID_LAST_SPECIAL + + chatlistPage.context.marknoticedChat(chatId) + + console.log("Selected chat " + chatId) + + console.log("Depth is " + pageStack.depth) + let chatPageComponent = Qt.createComponent("qrc:/qml/ChatPage.qml") + if (chatPageComponent.status == Component.Ready) { + let myPage = chatPageComponent.createObject(chatlistPage, {chatId: chatId, context: chatlistPage.context, eventEmitter: chatlistPage.eventEmitter}) + if (pageStack.depth == 1) { + pageStack.push(myPage) + } else if (pageStack.depth == 2) { + pageStack.currentIndex = 1 + pageStack.replace(myPage) + } + } else if (chatPageComponent.status == Component.Error) { + console.log("Error loading chat page: " + chatPageComponent.errorString()) } - } else if (chatPageComponent.status == Component.Error) { - console.log("Error loading chat page: " + chatPageComponent.errorString()) + } else if (chatId == 6) { + console.log("Clicked on archived chat link") } } -- cgit v1.2.3-54-g00ecf