diff --git a/src/jamidht/typers.cpp b/src/jamidht/typers.cpp index 1250e97a548b6a5c3132f7ee061d449b92dfcbf8..71c9538770ae87740cbb79c057a4962c5d93b38b 100644 --- a/src/jamidht/typers.cpp +++ b/src/jamidht/typers.cpp @@ -55,7 +55,7 @@ getIsComposing(const std::string& conversationId, bool isWriting) } void -Typers::addTyper(const std::string &typer) +Typers::addTyper(const std::string &typer, bool sendMessage) { auto acc = acc_.lock(); if (!acc || !acc->isComposingEnabled()) @@ -73,27 +73,30 @@ Typers::addTyper(const std::string &typer) if (typer != selfUri_) emitSignal<libjami::ConfigurationSignal::ComposingStatusChanged>(accountId_, - convId_, - typer, - 1); + convId_, + typer, + 1); + return; } - if (typer == selfUri_) { + if (sendMessage) { + // In this case we should emit for remote to update the timer acc->sendInstantMessage(convId_, {{MIME_TYPE_IM_COMPOSING, getIsComposing(convId_, true)}}); } } void -Typers::removeTyper(const std::string &typer) +Typers::removeTyper(const std::string &typer, bool sendMessage) { auto acc = acc_.lock(); if (!acc || !acc->isComposingEnabled()) return; if (watcher_.erase(typer)) { - if (typer == selfUri_) { + if (sendMessage) { acc->sendInstantMessage(convId_, {{MIME_TYPE_IM_COMPOSING, getIsComposing(convId_, false)}}); - } else { + } + if (typer != selfUri_) { emitSignal<libjami::ConfigurationSignal::ComposingStatusChanged>(accountId_, convId_, typer, diff --git a/src/jamidht/typers.h b/src/jamidht/typers.h index 5d177e30bd701e4732e5b1bfdd79db3f2dfeef39..eb0badc5eba6639b0ba7bdd5f702f8d5bc70f914 100644 --- a/src/jamidht/typers.h +++ b/src/jamidht/typers.h @@ -34,8 +34,13 @@ public: Typers(const std::shared_ptr<JamiAccount>& acc, const std::string &convId); ~Typers(); - void addTyper(const std::string &typer); - void removeTyper(const std::string &typer); + /** + * Add typer to the list of typers + * @param typer + * @param sendMessage (should be true for local typer, false for remote typer) + */ + void addTyper(const std::string &typer, bool sendMessage = false); + void removeTyper(const std::string &typer, bool sendMessage = false); private: void onTyperTimeout(const asio::error_code& ec, const std::string &typer);