Merge pull request #248 from jgibbon/feature/overviewpage-speedup

speed up overview page loading
This commit is contained in:
Sebastian Wolf 2020-12-26 14:50:55 +01:00 committed by GitHub
commit 13f21916f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 113 additions and 127 deletions

View file

@ -24,7 +24,23 @@ PhotoTextsListItem {
isSecret: ( chat_type === TelegramAPI.ChatTypeSecret )
openMenuOnPressAndHold: true//chat_id != overviewPage.ownUserId
menu: ContextMenu {
onPressAndHold: {
contextMenuLoader.active = true;
}
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: {
@ -59,5 +75,7 @@ PhotoTextsListItem {
text: model.display.type['@type'] === "chatTypePrivate" ? qsTr("User Info") : qsTr("Group Info")
}
}
}
}
}

View file

@ -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")
}
}
}
}
}

View file

@ -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,15 +216,10 @@ Page {
}
}
Column {
id: column
width: parent.width
height: parent.height
spacing: Theme.paddingMedium
Row {
id: headerRow
width: parent.width
PageHeader {
id: pageHeader
title: qsTr("Fernschreiber")
leftMargin: Theme.itemSizeMedium
GlassItem {
id: pageStatus
@ -229,50 +230,29 @@ Page {
radius: 0.2
cache: false
}
PageHeader {
id: pageHeader
title: qsTr("Fernschreiber")
width: parent.width - pageStatus.width
}
}
Item {
id: chatListItem
width: parent.width
height: parent.height - Theme.paddingMedium - headerRow.height
SilicaListView {
id: chatListView
anchors.fill: parent
anchors {
top: pageHeader.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
}
clip: true
opacity: overviewPage.chatListCreated ? 1 : 0
Behavior on opacity { NumberAnimation {} }
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
})
}
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 {
@ -285,12 +265,11 @@ Page {
Column {
width: parent.width
height: loadingLabel.height + loadingBusyIndicator.height + Theme.paddingMedium
spacing: Theme.paddingMedium
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenter: chatListView.verticalCenter
opacity: overviewPage.chatListCreated ? 0 : 1
Behavior on opacity { NumberAnimation {} }
Behavior on opacity { FadeAnimation {} }
visible: !overviewPage.chatListCreated
InfoLabel {
@ -306,6 +285,4 @@ Page {
}
}
}
}
}
}