Start chat from @-mention

This commit is contained in:
Sebastian Wolf 2020-11-03 22:21:01 +01:00
parent 23d0af9836
commit bbd8e3eabf
3 changed files with 14 additions and 4 deletions

View file

@ -224,7 +224,7 @@ function enhanceMessageText(formattedText) {
messageInsertions.push(new MessageInsertion((formattedText.entities[i].offset + formattedText.entities[i].length), "</i>", 0 ));
}
if (entityType === "textEntityTypeMention") {
messageInsertions.push(new MessageInsertion(formattedText.entities[i].offset, "<a href=\"user:" + messageText.substring(formattedText.entities[i].offset, ( formattedText.entities[i].offset + formattedText.entities[i].length )) + "\">", 0 ));
messageInsertions.push(new MessageInsertion(formattedText.entities[i].offset, "<a href=\"user://" + messageText.substring(formattedText.entities[i].offset, ( formattedText.entities[i].offset + formattedText.entities[i].length )) + "\">", 0 ));
messageInsertions.push(new MessageInsertion((formattedText.entities[i].offset + formattedText.entities[i].length), "</a>", 0 ));
}
if (entityType === "textEntityTypeMentionName") {
@ -277,9 +277,10 @@ function enhanceMessageText(formattedText) {
function handleLink(link) {
if (link.indexOf("user://") === 0) {
//pageStack.push(Qt.resolvedUrl("../pages/UserPage.qml"), {"userName": link.substring(7)});
} else if (link.indexOf("userid://") === 0) {
//pageStack.push(Qt.resolvedUrl("../pages/UserPage.qml"), {"userId": link.substring(9)});
var userInformation = tdLibWrapper.getUserInformationByName(link.substring(8));
tdLibWrapper.createPrivateChat(userInformation.id);
} else if (link.indexOf("userId://") === 0) {
tdLibWrapper.createPrivateChat(link.substring(9));
} else {
Qt.openUrlExternally(link);
}

View file

@ -708,6 +708,11 @@ QVariantMap TDLibWrapper::getUserInformation(const QString &userId)
return this->allUsers.value(userId).toMap();
}
QVariantMap TDLibWrapper::getUserInformationByName(const QString &userName)
{
return this->allUserNames.value(userName).toMap();
}
QVariantMap TDLibWrapper::getUnreadMessageInformation()
{
return this->unreadMessageInformation;
@ -898,6 +903,7 @@ void TDLibWrapper::handleUserUpdated(const QVariantMap &userInformation)
}
LOG("User information updated:" << userInformation.value("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);
emit userUpdated(updatedUserId, userInformation);
}
@ -911,6 +917,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);
emit userUpdated(userId, updatedUserInformation);
}

View file

@ -92,6 +92,7 @@ public:
Q_INVOKABLE TDLibWrapper::ConnectionState getConnectionState();
Q_INVOKABLE QVariantMap getUserInformation();
Q_INVOKABLE QVariantMap getUserInformation(const QString &userId);
Q_INVOKABLE QVariantMap getUserInformationByName(const QString &userName);
Q_INVOKABLE QVariantMap getUnreadMessageInformation();
Q_INVOKABLE QVariantMap getUnreadChatInformation();
Q_INVOKABLE QVariantMap getBasicGroup(qlonglong groupId) const;
@ -239,6 +240,7 @@ private:
QVariantMap options;
QVariantMap userInformation;
QVariantMap allUsers;
QVariantMap allUserNames;
QVariantMap chats;
QVariantMap unreadMessageInformation;
QVariantMap unreadChatInformation;