Commit 9d0011fe authored by Ming Rui Zhang's avatar Ming Rui Zhang

messagewebview: add typing indicator support

Change-Id: I69ecb47073ae54a2c8f887598381794df54ef3ef
parent 571566bd
......@@ -942,6 +942,8 @@ CallWidget::setupChatView(const lrc::api::conversation::Info& convInfo)
ui->sendContactRequestButton->setVisible(shouldShowSendContactRequestBtn);
ui->messageView->setMessagesVisibility(false);
connect(LRCInstance::getCurrentConversationModel(), &ConversationModel::composingStatusChanged, ui->messageView, &MessageWebView::contactIsComposing);
Utils::oneShotConnect(ui->messageView, &MessageWebView::sendMessageContentSaved,
[this, convInfo, accountId = accountInfo.id, lastConvUid = lastConvUid_](const QString& content) {
if (!lastConvUid.isEmpty()) {
......
......@@ -129,6 +129,7 @@ MessageWebView::MessageWebView(QWidget *parent)
fullScreenWebWidget_.reset();
}
});
}
MessageWebView::~MessageWebView()
......@@ -505,6 +506,15 @@ MessageWebView::setSendMessageContent(const QString& content)
page()->runJavaScript(s, QWebEngineScript::MainWorld);
}
void
MessageWebView::contactIsComposing(const QString& uid, const QString& contactUri, bool isComposing)
{
if (LRCInstance::getCurrentConvUid() == uid) {
QString s = QString::fromLatin1("showTypingIndicator(`%1`, %2);").arg(contactUri).arg(isComposing);
page()->runJavaScript(s, QWebEngineScript::MainWorld);
}
}
// JS bridging incoming
Q_INVOKABLE int
PrivateBridging::log(const QString& arg)
......@@ -784,7 +794,13 @@ PrivateBridging::saveSendMessageContent(const QString& arg)
qDebug() << "JS bridging - exception during saveSendMessageContent!";
}
return 0;
}
Q_INVOKABLE int
PrivateBridging::onComposing(bool isComposing)
{
LRCInstance::getCurrentConversationModel()->setIsComposing(LRCInstance::getCurrentConvUid(), isComposing);
return 0;
}
FullScreenWebWidget::FullScreenWebWidget(QWebEngineView *oldView, QWidget *parent)
......
......@@ -63,6 +63,7 @@ public:
Q_INVOKABLE int openAudioRecorder(int spikePosX,int spikePosY);
Q_INVOKABLE int openVideoRecorder(int spikePosX,int spikePosY);
Q_INVOKABLE int saveSendMessageContent(const QString& arg);
Q_INVOKABLE int onComposing(bool isComposing);
};
class MessageWebView : public QWebEngineView
......@@ -109,6 +110,7 @@ public:
void displayNavbar(bool display);
void requestSendMessageContent();
void setSendMessageContent(const QString& content);
void contactIsComposing(const QString& uid, const QString& contactUri, bool isComposing);
protected:
......
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