From 653a35500ca68a6b91f04e7778a7b84609e41e4d Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Fri, 25 Dec 2020 23:09:23 +0100 Subject: [PATCH 1/3] speed up overview page loading contributes to #198 --- qml/components/ChatListViewItem.qml | 74 +++++---- .../ChatInformationTabItemMembersGroups.qml | 9 - qml/pages/OverviewPage.qml | 157 ++++++++---------- 3 files changed, 113 insertions(+), 127 deletions(-) diff --git a/qml/components/ChatListViewItem.qml b/qml/components/ChatListViewItem.qml index 4644efc..9ed98f4 100644 --- a/qml/components/ChatListViewItem.qml +++ b/qml/components/ChatListViewItem.qml @@ -24,39 +24,57 @@ PhotoTextsListItem { isSecret: ( chat_type === TelegramAPI.ChatTypeSecret ) openMenuOnPressAndHold: true//chat_id != overviewPage.ownUserId - menu: ContextMenu { - MenuItem { - visible: unread_count > 0 - onClicked: { - tdLibWrapper.viewMessage(chat_id, display.last_message.id, true); - } - text: qsTr("Mark all messages as read") - } - MenuItem { - visible: chat_id != listItem.ownUserId - onClicked: { - var newNotificationSettings = display.notification_settings; - if (newNotificationSettings.mute_for > 0) { - newNotificationSettings.mute_for = 0; - } else { - newNotificationSettings.mute_for = 6666666; - } - newNotificationSettings.use_default_mute_for = false; - tdLibWrapper.setChatNotificationSettings(chat_id, newNotificationSettings); - } - text: display.notification_settings.mute_for > 0 ? qsTr("Unmute Chat") : qsTr("Mute Chat") - } + onPressAndHold: { + contextMenuLoader.active = true; + } - MenuItem { - onClicked: { - if(pageStack.depth > 2) { - pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} ), PageStackAction.Immediate); + Loader { + id: contextMenuLoader + active: false + asynchronous: true + onStatusChanged: { + if(status === Loader.Ready) { + listItem.menu = item; + listItem.openMenu(); + } + } + sourceComponent: Component { + ContextMenu { + MenuItem { + visible: unread_count > 0 + onClicked: { + tdLibWrapper.viewMessage(chat_id, display.last_message.id, true); + } + text: qsTr("Mark all messages as read") } - pageStack.push(Qt.resolvedUrl("../pages/ChatInformationPage.qml"), { "chatInformation" : display}); + MenuItem { + visible: chat_id != listItem.ownUserId + onClicked: { + var newNotificationSettings = display.notification_settings; + if (newNotificationSettings.mute_for > 0) { + newNotificationSettings.mute_for = 0; + } else { + newNotificationSettings.mute_for = 6666666; + } + newNotificationSettings.use_default_mute_for = false; + tdLibWrapper.setChatNotificationSettings(chat_id, newNotificationSettings); + } + text: display.notification_settings.mute_for > 0 ? qsTr("Unmute Chat") : qsTr("Mute Chat") + } + + MenuItem { + onClicked: { + if(pageStack.depth > 2) { + pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} ), PageStackAction.Immediate); + } + + pageStack.push(Qt.resolvedUrl("../pages/ChatInformationPage.qml"), { "chatInformation" : display}); + } + text: model.display.type['@type'] === "chatTypePrivate" ? qsTr("User Info") : qsTr("Group Info") + } } - text: model.display.type['@type'] === "chatTypePrivate" ? qsTr("User Info") : qsTr("Group Info") } } diff --git a/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml b/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml index 9c898bb..79a72db 100644 --- a/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml +++ b/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml @@ -154,15 +154,6 @@ ChatInformationTabItemBase { pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} ), PageStackAction.Immediate); pageStack.push(Qt.resolvedUrl("../../pages/ChatPage.qml"), { "chatInformation" : display }); } - Connections { - target: chatListModel - onChatChanged: { - if (changedChatId === chat_id) { - // Force update of some list item elements (currently only last message text seems to create problems). dataChanged() doesn't seem to trigger them all :( - secondaryText.text = last_message_text ? Emoji.emojify(Functions.enhanceHtmlEntities(last_message_text), Theme.fontSizeExtraSmall) : qsTr("Unknown") - } - } - } } } diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml index e89ab24..be5f166 100644 --- a/qml/pages/OverviewPage.qml +++ b/qml/pages/OverviewPage.qml @@ -59,13 +59,13 @@ Page { Timer { id: chatListCreatedTimer - interval: 300 + interval: 20 running: false repeat: false onTriggered: { overviewPage.chatListCreated = true; - chatListModel.redrawModel(); chatListView.scrollToTop(); + updateSecondaryContentTimer.start(); } } @@ -76,6 +76,15 @@ Page { pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml")); } } + Timer { + id: updateSecondaryContentTimer + interval: 600 + onTriggered: { + tdLibWrapper.getRecentStickers(); + tdLibWrapper.getInstalledStickerSets(); + tdLibWrapper.getContacts(); + } + } function setPageStatus() { switch (overviewPage.connectionState) { @@ -104,9 +113,6 @@ Page { function updateContent() { tdLibWrapper.getChats(); - tdLibWrapper.getRecentStickers(); - tdLibWrapper.getInstalledStickerSets(); - tdLibWrapper.getContacts(); } function initializePage() { @@ -210,101 +216,72 @@ Page { } } - Column { - id: column - width: parent.width - height: parent.height - spacing: Theme.paddingMedium + PageHeader { + id: pageHeader + title: qsTr("Fernschreiber") + leftMargin: Theme.itemSizeMedium - Row { - id: headerRow - width: parent.width + GlassItem { + id: pageStatus + width: Theme.itemSizeMedium + height: Theme.itemSizeMedium + color: "red" + falloffRadius: 0.1 + radius: 0.2 + cache: false + } + } - GlassItem { - id: pageStatus - width: Theme.itemSizeMedium - height: Theme.itemSizeMedium - color: "red" - falloffRadius: 0.1 - radius: 0.2 - cache: false - } - - PageHeader { - id: pageHeader - title: qsTr("Fernschreiber") - width: parent.width - pageStatus.width + SilicaListView { + id: chatListView + anchors { + top: pageHeader.bottom + bottom: parent.bottom + left: parent.left + right: parent.right + } + clip: true + opacity: overviewPage.chatListCreated ? 1 : 0 + Behavior on opacity { FadeAnimation {} } + model: chatListModel + delegate: ChatListViewItem { + ownUserId: overviewPage.ownUserId + isVerified: is_verified + onClicked: { + pageStack.push(Qt.resolvedUrl("../pages/ChatPage.qml"), { + chatInformation : display, + chatPicture: photo_small + }) } } - Item { - id: chatListItem - width: parent.width - height: parent.height - Theme.paddingMedium - headerRow.height + ViewPlaceholder { + enabled: chatListView.count === 0 + text: qsTr("You don't have any chats yet.") + } - SilicaListView { + VerticalScrollDecorator {} + } - id: chatListView + Column { + width: parent.width + spacing: Theme.paddingMedium + anchors.verticalCenter: chatListView.verticalCenter - anchors.fill: parent + opacity: overviewPage.chatListCreated ? 0 : 1 + Behavior on opacity { FadeAnimation {} } + visible: !overviewPage.chatListCreated - clip: true - opacity: overviewPage.chatListCreated ? 1 : 0 - Behavior on opacity { NumberAnimation {} } + InfoLabel { + id: loadingLabel + text: qsTr("Loading chat list...") + } - model: chatListModel - delegate: ChatListViewItem { - ownUserId: overviewPage.ownUserId - isVerified: is_verified - - onClicked: { - pageStack.push(Qt.resolvedUrl("../pages/ChatPage.qml"), { - chatInformation : display, - chatPicture: photo_small - }) - } - - Connections { - target: chatListModel - onChatChanged: { - if (overviewPage.chatListCreated && changedChatId === chat_id) { - // Force update of some list item elements (currently only last message text seems to create problems). dataChanged() doesn't seem to trigger them all :( - secondaryText.text = last_message_text ? Emoji.emojify(Functions.enhanceHtmlEntities(last_message_text), Theme.fontSizeExtraSmall) : qsTr("Unknown") - } - } - } - } - - ViewPlaceholder { - enabled: chatListView.count === 0 - text: qsTr("You don't have any chats yet.") - } - - VerticalScrollDecorator {} - } - - Column { - width: parent.width - height: loadingLabel.height + loadingBusyIndicator.height + Theme.paddingMedium - spacing: Theme.paddingMedium - anchors.verticalCenter: parent.verticalCenter - - opacity: overviewPage.chatListCreated ? 0 : 1 - Behavior on opacity { NumberAnimation {} } - visible: !overviewPage.chatListCreated - - InfoLabel { - id: loadingLabel - text: qsTr("Loading chat list...") - } - - BusyIndicator { - id: loadingBusyIndicator - anchors.horizontalCenter: parent.horizontalCenter - running: !overviewPage.chatListCreated - size: BusyIndicatorSize.Large - } - } + BusyIndicator { + id: loadingBusyIndicator + anchors.horizontalCenter: parent.horizontalCenter + running: !overviewPage.chatListCreated + size: BusyIndicatorSize.Large } } } From d619b97ee4401c2bc2d92e0d05a795ac864fbf3e Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 26 Dec 2020 14:58:10 +0100 Subject: [PATCH 2/3] Increase chatListCreatedTimer to 100ms, update translation files --- qml/pages/OverviewPage.qml | 2 +- translations/harbour-fernschreiber-de.ts | 8 -------- translations/harbour-fernschreiber-en.ts | 8 -------- translations/harbour-fernschreiber-es.ts | 8 -------- translations/harbour-fernschreiber-fi.ts | 8 -------- translations/harbour-fernschreiber-hu.ts | 8 -------- translations/harbour-fernschreiber-it.ts | 8 -------- translations/harbour-fernschreiber-pl.ts | 8 -------- translations/harbour-fernschreiber-ru.ts | 8 -------- translations/harbour-fernschreiber-sv.ts | 8 -------- translations/harbour-fernschreiber-zh_CN.ts | 8 -------- translations/harbour-fernschreiber.ts | 8 -------- 12 files changed, 1 insertion(+), 89 deletions(-) diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml index be5f166..928bb41 100644 --- a/qml/pages/OverviewPage.qml +++ b/qml/pages/OverviewPage.qml @@ -59,7 +59,7 @@ Page { Timer { id: chatListCreatedTimer - interval: 20 + interval: 100 running: false repeat: false onTriggered: { diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 4f8be73..6700c24 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -195,10 +195,6 @@ chats you have in common with a user Lade gemeinsame Chats… - - Unknown - Unbekannt - Loading group members… Lade Gruppenmitglieder… @@ -1014,10 +1010,6 @@ Updating content... Aktualisiere Inhalte... - - Unknown - Unbekannt - Loading chat list... Lade Chatliste... diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 503c588..e0d7413 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -191,10 +191,6 @@ chats you have in common with a user Loading common chats… - - Unknown - Unknown - Loading group members… Loading group members… @@ -1014,10 +1010,6 @@ Updating content... Updating content... - - Unknown - Unknown - Loading chat list... Loading chat list... diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 6a557ab..e55d8f4 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -188,10 +188,6 @@ chats you have in common with a user Cargando las charlas comunes… - - Unknown - Desconocido - Loading group members… Cargando miembros del grupo… @@ -1003,10 +999,6 @@ Updating content... Actualizando contenido... - - Unknown - desconocido - Loading chat list... cargando lista de charla... diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index d9f1dcc..92eec5c 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -191,10 +191,6 @@ chats you have in common with a user Ladataan yhteisiä keskusteluja... - - Unknown - Tuntematon - Loading group members… Ladataan ryhmän jäseniä... @@ -1015,10 +1011,6 @@ Updating content... Päivitetään sisältöä... - - Unknown - Tuntematon - Loading chat list... Ladataan keskustelulistaa... diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 3b6404c..627e8f1 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -188,10 +188,6 @@ chats you have in common with a user - - Unknown - Ismeretlen - Loading group members… @@ -1003,10 +999,6 @@ Updating content... Tartalom frissítése... - - Unknown - Ismeretlen - Loading chat list... Csevegés lista betöltése... diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index f7fdd66..dbb229d 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -190,10 +190,6 @@ You Tu - - Unknown - Sconosciuto - You don't have any groups in common with this user. Non hai nessun gruppo in comune con questo utente. @@ -998,10 +994,6 @@ Fernschreiber Fernschreiber - - Unknown - Sconosciuto - Settings Impostazioni diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 022f13f..b09993b 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -194,10 +194,6 @@ chats you have in common with a user Ładowanie wspólnych czatów... - - Unknown - Nieznany - Loading group members… Ładowanie członków grupy @@ -1025,10 +1021,6 @@ Updating content... Aktualizacja treści... - - Unknown - Nieznany - Loading chat list... Ładowanie listy czatu... diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 567fe61..8842bad 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -194,10 +194,6 @@ chats you have in common with a user Загрузка общих чатов… - - Unknown - нет информации - Loading group members… Загрузка списка участников… @@ -1025,10 +1021,6 @@ Updating content... Обновление контента... - - Unknown - Неизвестный - Loading chat list... Загрузка чатов... diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 01e9690..38e9527 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -191,10 +191,6 @@ chats you have in common with a user Läser in gemensamma chattar... - - Unknown - Okänd - Loading group members… Läser in gruppmedlemmar... @@ -1014,10 +1010,6 @@ Updating content... Uppdaterar innehåll... - - Unknown - Okänd - Loading chat list... Läser in chattlistan... diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 3bfd943..1c65bcd 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -188,10 +188,6 @@ chats you have in common with a user 正在加载共有对话… - - Unknown - 未知 - Loading group members… 正在加载群组成员… @@ -1003,10 +999,6 @@ Updating content... 正在更新内容… - - Unknown - 未知 - Loading chat list... 正在加载对话列表… diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index e84fe15..1d93a30 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -191,10 +191,6 @@ chats you have in common with a user Loading common chats… - - Unknown - Unknown - Loading group members… Loading group members… @@ -1014,10 +1010,6 @@ Updating content... Updating content... - - Unknown - Unknown - Loading chat list... Loading chat list... From 13a91fa0e7d364fa78f8436e733300ef8bd4b186 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 26 Dec 2020 15:43:10 +0100 Subject: [PATCH 3/3] Remove pinned message workaround, add more build information --- README.md | 14 ++++++++++++++ src/tdlibwrapper.cpp | 9 +-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d1f8fb1..f2ae92a 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,20 @@ Moreover, you need to have a compiled version of [TDLib 1.7](https://github.com/ In case you encounter strange performance issues on startup (several seconds delay, app seems to do nothing), please be sure to [follow the instructions from the respective GitHub issue](https://github.com/tdlib/td/issues/1322), i.e. let TDLib build SQLite with `-DOMIT_MEMLOCK` and be sure to comment the two lines 22558 (`#ifndef OMIT_MEMLOCK`) and 22567 (`#endif`) in the file `sqlite/sqlite/sqlite3.c`. +Moreover, TDLib 1.7 has issues loading some pinned messages in case the message database is used (which is the case in Fernschreiber). [A small patch](https://github.com/tdlib/td/commit/30d912bd4b145afb8d494b307d37645ffa21ec29) is required to make TDLib work properly in all cases. See [the respective TDLib issue](https://github.com/tdlib/td/issues/1343) for more details. + +In case you want to use the same codebase which was used to compile the library that is shipped with Fernschreiber, please [check out the fork](https://github.com/Wunderfitz/td), be sure to use the branch `fernschreiber` and compile these sources using the following commands (be sure to have the Sailfish OS build engine running): + +- `alias sfdk=~/SailfishOS/bin/sfdk` +- `sfdk config target=SailfishOS-3.3.0.16-armv7hl` (this compiles the sources on SFOS 3.3 and ARM - the target needs to be adjusted according to the running SDK engine and the platform) +- `mkdir build` +- `cd build` +- `sfdk build-shell cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../tdlib -DTD_ENABLE_LTO=ON ..` (in case of compilation issues, try removing the flag `-DTD_ENABLE_LTO=ON`) +- `sfdk build-shell cmake --build . --target install` + +You'll find the compiled library in the directory `td/tdlib`. + + ## Debug Fernschreiber does only output a few TDLib messages by default. To get its own debug log messages, you can either run a debug build to see all of them or use the environment variable `QT_LOGGING_RULES` to specify/filter which messages you'd like to see. diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 5e3ed51..42223a1 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1300,15 +1300,8 @@ void TDLibWrapper::handleMessageInformation(const QString &messageId, const QVar QString extraInformation = receivedInformation.value(_EXTRA).toString(); if (extraInformation.startsWith("getChatPinnedMessage")) { emit chatPinnedMessageUpdated(receivedInformation.value(CHAT_ID).toLongLong(), messageId.toLongLong()); - // Sometimes it seems that pinned messages aren't returned as pinned ones, weird! - // This is a workaround for now, let's see what comes out of https://github.com/tdlib/td/issues/1343 - QVariantMap updatedInformation(receivedInformation); - updatedInformation.insert("is_pinned", true); - emit receivedMessage(messageId, updatedInformation); - } else { - emit receivedMessage(messageId, receivedInformation); } - + emit receivedMessage(messageId, receivedInformation); } void TDLibWrapper::handleMessageIsPinnedUpdated(qlonglong chatId, qlonglong messageId, bool isPinned)