Commit 07089458 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Fix "message not sent" issue (when clicking a banner while in chat page)

parent 5cd52f90
......@@ -64,7 +64,7 @@ ApplicationWindow {
target: TD_Global;
onShowChatRequested: {
if (chatItem) {
console.log ("DISPLAY REQUESTED", chatItem.id);
console.log ("DISPLAY REQUESTED", chatItem, chatItem.id);
window.activate ();
while (pageStack.depth > 1) {
pageStack.navigateBack (PageStackAction.Immediate);
......
......@@ -8,6 +8,7 @@ Page {
id: page;
allowedOrientations: Orientation.All;
Component.onCompleted: {
console.log ("CHAT PAGE completed", currentChat);
TD_Global.openChat (currentChat);
if (currentChat.unreadCount > 0) {
// should wait for first unread msg to become valid and center on it
......@@ -18,6 +19,7 @@ Page {
}
}
Component.onDestruction: {
console.log ("CHAT PAGE destroyed", currentChat);
TD_Global.closeChat (currentChat);
}
onContainsFirstUnreadMsgChanged: {
......
......@@ -53,7 +53,7 @@ QtTdLibChat::QtTdLibChat (const qint64 id, QObject * parent)
}
});
connect (&m_notif, &Notification::clicked, this, [this] (void) {
qWarning () << "CLICKED" << get_id ();
qWarning () << "CLICKED" << this << get_id ();
emit displayRequested ();
});
connect (this, &QtTdLibChat::lastReadInboxMessageIdChanged, this, &QtTdLibChat::findFirstNewMessage);
......
......@@ -325,12 +325,13 @@ void QtTdLibGlobal::createPrivateChat (QtTdLibUser * userItem) {
void QtTdLibGlobal::showChat (QtTdLibChat * chatItem) {
if (chatItem != Q_NULLPTR) {
qWarning () << "SHOW CHAT" << chatItem->get_id () << chatItem->get_title ();
qWarning () << "SHOW CHAT" << chatItem << chatItem->get_id () << chatItem->get_title ();
emit showChatRequested (chatItem);
}
}
void QtTdLibGlobal::openChat (QtTdLibChat * chatItem) {
qWarning () << "openChat" << chatItem;
closeChat (m_currentChat);
if (chatItem != Q_NULLPTR) {
chatItem->set_isCurrentChat (true);
......@@ -344,15 +345,16 @@ void QtTdLibGlobal::openChat (QtTdLibChat * chatItem) {
}
void QtTdLibGlobal::closeChat (QtTdLibChat * chatItem) {
set_replyingToMessageId ("");
set_currentMessageContent (Q_NULLPTR);
if (chatItem != Q_NULLPTR) {
qWarning () << "closeChat" << chatItem;
if (chatItem != Q_NULLPTR && chatItem == m_currentChat) {
chatItem->messagesModel.clear ();
chatItem->set_oldestFetchedMessageId (0); // NOTE : reset lower boundary
chatItem->set_newestFetchedMessageId (0); // NOTE : reset upper boundary
chatItem->set_hasReachedFirst (false); // NOTE : reset start flag
chatItem->set_hasReachedLast (false); // NOTE : reset end flag
chatItem->set_isCurrentChat (false);
set_replyingToMessageId ("");
set_currentMessageContent (Q_NULLPTR);
set_currentChat (Q_NULLPTR);
send (QJsonObject {
{ "@type", "closeChat" },
......@@ -551,6 +553,7 @@ QJsonValue QtTdLibGlobal::createFormattedTextJson (const QString & text) {
}
void QtTdLibGlobal::sendMessageText (QtTdLibChat * chatItem, const QString & text) {
qWarning () << "sendMessageText" << chatItem << text;
if (chatItem != Q_NULLPTR && !text.isEmpty ()) {
send (QJsonObject {
{ "@type", "sendMessage" },
......
......@@ -120,9 +120,9 @@ public:
Q_INVOKABLE void sendMessageVoiceNote (QtTdLibChat * chatItem, const QString & recording);
Q_INVOKABLE void sendMessageSticker (QtTdLibChat * chatItem, QtTdLibSticker * stickerItem);
Q_INVOKABLE bool startRecordingAudio (void);
Q_INVOKABLE QString stopRecordingAudio (void);
Q_INVOKABLE void removeRecording (const QString & path);
Q_INVOKABLE bool startRecordingAudio (void);
Q_INVOKABLE QString stopRecordingAudio (void);
Q_INVOKABLE void removeRecording (const QString & path);
signals:
void showChatRequested (QtTdLibChat * chatItem);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment