Don't display empty in-reply-to section if message wasn't found

This commit is contained in:
Sebastian Wolf 2020-12-25 15:33:53 +01:00
parent ff399a524c
commit 4e680a9a3f
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
5 changed files with 20 additions and 4 deletions

View file

@ -170,6 +170,11 @@ ListItem {
messageInReplyToLoader.inReplyToMessage = message;
}
}
onMessageNotFound: {
if (messageId === myMessage.reply_to_message_id) {
messageInReplyToLoader.active = false;
}
}
}
Component.onCompleted: {

View file

@ -528,7 +528,7 @@ void TDLibReceiver::processUsers(const QVariantMap &receivedInformation)
void TDLibReceiver::processError(const QVariantMap &receivedInformation)
{
LOG("Received an error");
emit errorReceived(receivedInformation.value("code").toInt(), receivedInformation.value(MESSAGE).toString());
emit errorReceived(receivedInformation.value("code").toInt(), receivedInformation.value(MESSAGE).toString(), receivedInformation.value(EXTRA).toString());
}
void TDLibReceiver::nop(const QVariantMap &)

View file

@ -84,7 +84,7 @@ signals:
void chatTitleUpdated(const QString &chatId, const QString &title);
void chatPinnedMessageUpdated(qlonglong chatId, qlonglong pinnedMessageId);
void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers);
void errorReceived(const int code, const QString &message);
void errorReceived(const int code, const QString &message, const QString &extra);
void secretChat(qlonglong secretChatId, const QVariantMap &secretChat);
void secretChatUpdated(qlonglong secretChatId, const QVariantMap &secretChat);
void contactsImported(const QVariantList &importerCount, const QVariantList &userIds);

View file

@ -119,7 +119,7 @@ TDLibWrapper::TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface,
connect(this->tdLibReceiver, SIGNAL(chatTitleUpdated(QString, QString)), this, SIGNAL(chatTitleUpdated(QString, QString)));
connect(this->tdLibReceiver, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong)), this, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong)));
connect(this->tdLibReceiver, SIGNAL(usersReceived(QString, QVariantList, int)), this, SIGNAL(usersReceived(QString, QVariantList, int)));
connect(this->tdLibReceiver, SIGNAL(errorReceived(int, QString)), this, SIGNAL(errorReceived(int, QString)));
connect(this->tdLibReceiver, SIGNAL(errorReceived(int, QString, QString)), this, SLOT(handleErrorReceived(int, QString, QString)));
connect(this->tdLibReceiver, SIGNAL(contactsImported(QVariantList, QVariantList)), this, SIGNAL(contactsImported(QVariantList, QVariantList)));
connect(&emojiSearchWorker, SIGNAL(searchCompleted(QString, QVariantList)), this, SLOT(handleEmojiSearchCompleted(QString, QVariantList)));
@ -537,6 +537,7 @@ void TDLibWrapper::getMessage(const QString &chatId, const QString &messageId)
requestObject.insert(_TYPE, "getMessage");
requestObject.insert("chat_id", chatId);
requestObject.insert("message_id", messageId);
requestObject.insert(_EXTRA, "getMessage:" + messageId);
this->sendRequest(requestObject);
}
@ -1272,6 +1273,14 @@ void TDLibWrapper::handleStorageOptimizerChanged()
setOptionBoolean("use_storage_optimizer", appSettings->storageOptimizer());
}
void TDLibWrapper::handleErrorReceived(const int code, const QString &message, const QString &extra)
{
if (code == 404 && extra.startsWith("getMessage:")) {
emit messageNotFound(extra.mid(11).toLongLong());
}
emit errorReceived(code, message, extra);
}
void TDLibWrapper::setInitialParameters()
{
LOG("Sending initial parameters to TD Lib");

View file

@ -242,8 +242,9 @@ signals:
void chatTitleUpdated(const QString &chatId, const QString &title);
void chatPinnedMessageUpdated(qlonglong chatId, qlonglong pinnedMessageId);
void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers);
void errorReceived(const int code, const QString &message);
void errorReceived(const int code, const QString &message, const QString &extra);
void contactsImported(const QVariantList &importerCount, const QVariantList &userIds);
void messageNotFound(const qlonglong messageId);
public slots:
void handleVersionDetected(const QString &version);
@ -265,6 +266,7 @@ public slots:
void handleSecretChatReceived(qlonglong secretChatId, const QVariantMap &secretChat);
void handleSecretChatUpdated(qlonglong secretChatId, const QVariantMap &secretChat);
void handleStorageOptimizerChanged();
void handleErrorReceived(const int code, const QString &message, const QString &extra);
private:
void setOption(const QString &name, const QString &type, const QVariant &value);