Fix multiple reactions from same account on message.

Update SDK to 5.3 branch
This commit is contained in:
Julien Wadel 2023-11-29 16:50:29 +01:00
parent 19f3823d5a
commit 53cbc2fa1c
3 changed files with 14 additions and 6 deletions

View file

@ -86,7 +86,9 @@ void ChatReactionListModel::clear(){
}
void ChatReactionListModel::updateChatReaction(const std::shared_ptr<const linphone::ChatMessageReaction>& reaction) {
QString address = Utils::coreStringToAppString(reaction->getFromAddress()->asStringUriOnly());
auto fromAddress = reaction->getFromAddress()->clone();
fromAddress->clean();
QString address = Utils::coreStringToAppString(fromAddress->asStringUriOnly());
auto itReaction = mReactions.find(address);
int oldReactionCount = mReactions.size();
auto oldBodies = getBodies();
@ -137,7 +139,9 @@ void ChatReactionListModel::updateList(){
}
bool ChatReactionListModel::exists(std::shared_ptr<linphone::ChatMessageReaction> reaction) const {
QString address = Utils::coreStringToAppString(reaction->getFromAddress()->asStringUriOnly());
auto fromAddress = reaction->getFromAddress()->clone();
fromAddress->clean();
QString address = Utils::coreStringToAppString(fromAddress->asStringUriOnly());
auto itReaction = mReactions.find(address);
if(itReaction != mReactions.end())
return (*itReaction)->getBody() == Utils::coreStringToAppString(reaction->getBody());
@ -181,11 +185,13 @@ void ChatReactionListModel::onNewMessageReaction(const std::shared_ptr<linphone:
updateChatReaction(reaction);
}
void ChatReactionListModel::onReactionRemoved(const std::shared_ptr<linphone::ChatMessage> & message, const std::shared_ptr<const linphone::Address> & address) {
mReactions.remove(Utils::coreStringToAppString(address->asStringUriOnly()));
auto fromAddress = address->clone();
fromAddress->clean();
mReactions.remove(Utils::coreStringToAppString(fromAddress->asStringUriOnly()));
mBodies.clear();
for(auto it : mReactions)
mBodies[it->getBody()].push_back(it);
updateList();
emit chatReactionCountChanged();
emit bodiesChanged();
}
}

View file

@ -28,7 +28,9 @@
ChatReactionModel::ChatReactionModel(const std::shared_ptr<const linphone::ChatMessageReaction>& reaction) {
App::getInstance()->getEngine()->setObjectOwnership(this, QQmlEngine::CppOwnership);// Avoid QML to destroy it when passing by Q_INVOKABLE
mBody = Utils::coreStringToAppString(reaction->getBody());
mFromAddress = Utils::coreStringToAppString(reaction->getFromAddress()->asStringUriOnly());
auto fromAddress = reaction->getFromAddress()->clone();
fromAddress->clean();
mFromAddress = Utils::coreStringToAppString(fromAddress->asStringUriOnly());
}
QString ChatReactionModel::getBody() const {

@ -1 +1 @@
Subproject commit a20e90babe7e6dc4def83720e7dce96ba3f917af
Subproject commit bf9106ee57b8a32aea2693f0fc69c2397a66d570