From 8531a46015c8235b4c0bc4f681c44ab4d558c2f2 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 19 Nov 2023 21:49:00 +0100 Subject: [PATCH] More places affected by new username handling --- qml/components/InlineQuery.qml | 2 +- qml/components/MessageViaLabel.qml | 4 ++-- qml/components/ReplyMarkupButtons.qml | 4 ++-- .../chatInformationPage/ChatInformationPageContent.qml | 4 ++-- qml/components/messageContent/MessageSticker.qml | 2 +- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- src/knownusersmodel.cpp | 6 +++--- src/tdlibwrapper.cpp | 8 +++++--- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/qml/components/InlineQuery.qml b/qml/components/InlineQuery.qml index 1ad7cb3..5f97fb2 100644 --- a/qml/components/InlineQuery.qml +++ b/qml/components/InlineQuery.qml @@ -40,7 +40,7 @@ Loader { property string chatId property string userName - property bool userNameIsValid: userName !== "" && inlineBotInformation && userName.toLowerCase() === inlineBotInformation.username.toLowerCase() + property bool userNameIsValid: userName !== "" && inlineBotInformation && userName.toLowerCase() === inlineBotInformation.usernames.editable_username.toLowerCase() property string query property int currentOffset: 0 property string responseExtra: chatId+"|"+userName+"|"+query+"|"+currentOffset diff --git a/qml/components/MessageViaLabel.qml b/qml/components/MessageViaLabel.qml index b76619e..b0d34d3 100644 --- a/qml/components/MessageViaLabel.qml +++ b/qml/components/MessageViaLabel.qml @@ -31,12 +31,12 @@ Loader { property var botUserInformation: tdLibWrapper.getUserInformation(message.via_bot_user_id) color: Theme.secondaryColor font.pixelSize: Theme.fontSizeExtraSmall - text: qsTr("via %1", "message posted via bot user").arg("@" + Emoji.emojify(botUserInformation.username, font.pixelSize)+"") + text: qsTr("via %1", "message posted via bot user").arg("@" + Emoji.emojify(botUserInformation.usernames.editable_username, font.pixelSize)+"") textFormat: Text.RichText truncationMode: TruncationMode.Fade onLinkActivated: { if(link === "userId://" + message.via_bot_user_id && botUserInformation.type.is_inline) { - newMessageTextField.text = "@"+botUserInformation.username+" " + newMessageTextField.text = "@"+botUserInformation.usernames.editable_username+" " newMessageTextField.cursorPosition = newMessageTextField.text.length lostFocusTimer.start(); } diff --git a/qml/components/ReplyMarkupButtons.qml b/qml/components/ReplyMarkupButtons.qml index de2cd2c..99efe97 100644 --- a/qml/components/ReplyMarkupButtons.qml +++ b/qml/components/ReplyMarkupButtons.qml @@ -60,12 +60,12 @@ Column { }, inlineKeyboardButtonTypeSwitchInline: function() { if(modelData.type.in_current_chat) { - chatPage.setMessageText("@" + userInformation.username + " "+(modelData.type.query || "")) + chatPage.setMessageText("@" + userInformation.usernames.editable_username + " "+(modelData.type.query || "")) } else { pageStack.push(Qt.resolvedUrl("../pages/ChatSelectionPage.qml"), { myUserId: chatPage.myUserId, - payload: { neededPermissions: ["can_send_other_messages"], text:"@" + userInformation.username + " "+(modelData.type.query || "")}, + payload: { neededPermissions: ["can_send_other_messages"], text:"@" + userInformation.usernames.editable_username + " "+(modelData.type.query || "")}, state: "fillTextArea" }) } diff --git a/qml/components/chatInformationPage/ChatInformationPageContent.qml b/qml/components/chatInformationPage/ChatInformationPageContent.qml index 511bc38..bbd1992 100644 --- a/qml/components/chatInformationPage/ChatInformationPageContent.qml +++ b/qml/components/chatInformationPage/ChatInformationPageContent.qml @@ -300,8 +300,8 @@ SilicaFlickable { } leftMargin: imageContainer.getEased((imageContainer.minDimension + Theme.paddingMedium), 0, imageContainer.tweenFactor) + Theme.horizontalPageMargin title: chatInformationPage.chatInformation.title !== "" ? Emoji.emojify(chatInformationPage.chatInformation.title, Theme.fontSizeLarge) : qsTr("Unknown") - description: ((chatInformationPage.isPrivateChat || chatInformationPage.isSecretChat) && chatInformationPage.privateChatUserInformation.username) - ? ("@"+chatInformationPage.privateChatUserInformation.username) : "" + description: ((chatInformationPage.isPrivateChat || chatInformationPage.isSecretChat) && chatInformationPage.privateChatUserInformation.usernames.editable_username) + ? ("@"+chatInformationPage.privateChatUserInformation.usernames.editable_username) : "" } SilicaFlickable { diff --git a/qml/components/messageContent/MessageSticker.qml b/qml/components/messageContent/MessageSticker.qml index ce499f8..fb9f02d 100644 --- a/qml/components/messageContent/MessageSticker.qml +++ b/qml/components/messageContent/MessageSticker.qml @@ -27,7 +27,7 @@ MessageContentBase { property var stickerData: messageListItem ? messageListItem.myMessage.content.sticker : overlayFlickable.overlayMessage.content.sticker; readonly property bool asEmoji: appSettings.showStickersAsEmojis - readonly property bool animated: stickerData.type["@type"] === "stickerTypeAnimated" && appSettings.animateStickers + readonly property bool animated: stickerData.format["@type"] === "stickerFormatTgs" && appSettings.animateStickers readonly property bool stickerVisible: staticStickerLoader.item ? staticStickerLoader.item.visible : animatedStickerLoader.item ? animatedStickerLoader.item.visible : false readonly property bool isOwnSticker : messageListItem ? messageListItem.isOwnMessage : overlayFlickable.isOwnMessage diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 84c153c..ea6c80f 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 2 +Release: 3 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 9580ba8..c374f3f 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 2 +Release: 3 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/src/knownusersmodel.cpp b/src/knownusersmodel.cpp index 50fdbd2..243cfeb 100644 --- a/src/knownusersmodel.cpp +++ b/src/knownusersmodel.cpp @@ -56,10 +56,10 @@ QVariant KnownUsersModel::data(const QModelIndex &index, int role) const case KnownUserRole::RoleDisplay: return requestedUser; case KnownUserRole::RoleUserId: return requestedUser.value("id"); case KnownUserRole::RoleTitle: return QString(requestedUser.value("first_name").toString() + " " + requestedUser.value("last_name").toString()).trimmed(); - case KnownUserRole::RoleUsername: return requestedUser.value("username"); - case KnownUserRole::RoleUserHandle: return QString("@" + (requestedUser.value("username").toString().isEmpty() ? requestedUser.value("id").toString() : requestedUser.value("username").toString())); + case KnownUserRole::RoleUsername: return requestedUser.value("usernames").toMap().value("editable_username").toString(); + case KnownUserRole::RoleUserHandle: return QString("@" + (requestedUser.value("usernames").toMap().value("editable_username").toString().isEmpty() ? requestedUser.value("id").toString() : requestedUser.value("usernames").toMap().value("editable_username").toString())); case KnownUserRole::RolePhotoSmall: return requestedUser.value("profile_photo").toMap().value("small"); - case KnownUserRole::RoleFilter: return QString(requestedUser.value("first_name").toString() + " " + requestedUser.value("last_name").toString() + " " + requestedUser.value("username").toString()).trimmed(); + case KnownUserRole::RoleFilter: return QString(requestedUser.value("first_name").toString() + " " + requestedUser.value("last_name").toString() + " " + requestedUser.value("usernames").toMap().value("editable_username").toString()).trimmed(); } } return QVariant(); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 646ac20..ffa902d 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -48,6 +48,8 @@ namespace { const QString LAST_NAME("last_name"); const QString FIRST_NAME("first_name"); const QString USERNAME("username"); + const QString USERNAMES("usernames"); + const QString EDITABLE_USERNAME("editable_username"); const QString THREAD_ID("thread_id"); const QString VALUE("value"); const QString CHAT_LIST_TYPE("chat_list_type"); @@ -1829,9 +1831,9 @@ void TDLibWrapper::handleUserUpdated(const QVariantMap &userInformation) this->userInformation = userInformation; emit ownUserUpdated(userInformation); } - LOG("User information updated:" << userInformation.value(USERNAME).toString() << userInformation.value(FIRST_NAME).toString() << userInformation.value(LAST_NAME).toString()); + LOG("User information updated:" << userInformation.value(USERNAMES).toMap().value(EDITABLE_USERNAME).toString() << userInformation.value(FIRST_NAME).toString() << userInformation.value(LAST_NAME).toString()); this->allUsers.insert(updatedUserId, userInformation); - this->allUserNames.insert(userInformation.value(USERNAME).toString(), userInformation); + this->allUserNames.insert(userInformation.value(USERNAMES).toMap().value(EDITABLE_USERNAME).toString(), userInformation); emit userUpdated(updatedUserId, userInformation); } @@ -1845,7 +1847,7 @@ void TDLibWrapper::handleUserStatusUpdated(const QString &userId, const QVariant QVariantMap updatedUserInformation = this->allUsers.value(userId).toMap(); updatedUserInformation.insert(STATUS, userStatusInformation); this->allUsers.insert(userId, updatedUserInformation); - this->allUserNames.insert(userInformation.value(USERNAME).toString(), userInformation); + this->allUserNames.insert(userInformation.value(USERNAMES).toMap().value(EDITABLE_USERNAME).toString(), userInformation); emit userUpdated(userId, updatedUserInformation); }