diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index b102e81..1204f6f 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -170,6 +170,11 @@ ListItem { messageInReplyToLoader.inReplyToMessage = message; } } + onMessageNotFound: { + if (messageId === myMessage.reply_to_message_id) { + messageInReplyToLoader.active = false; + } + } } Component.onCompleted: { diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index aaca176..94000b2 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -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 &) diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index 7194e36..42ea9aa 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -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); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 8128178..785a834 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -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"); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index fd9520e..d41cdb4 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -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);