Update participant identification in removal/admim-toggle inside rooms (cherry pick 929feffc6f5f343fde931ce4c4dfccab0eb26f23 from quanta/master)

This commit is contained in:
Gaelle Braud 2026-03-06 15:42:38 +01:00
parent 836fe17a35
commit 9ec465763f
5 changed files with 21 additions and 16 deletions

View file

@ -396,17 +396,17 @@ void ChatCore::setSelf(const QSharedPointer<ChatCore> &me) {
} }
mChatModelConnection->invokeToCore([this, success] { emit participantAddressesChanged(success); }); mChatModelConnection->invokeToCore([this, success] { emit participantAddressesChanged(success); });
}); });
mChatModelConnection->makeConnectToCore(&ChatCore::lRemoveParticipantAtIndex, [this](int index) { mChatModelConnection->makeConnectToCore(&ChatCore::lRemoveParticipant, [this](QString sipAddress) {
mChatModelConnection->invokeToModel([this, index]() { mChatModel->removeParticipantAtIndex(index); }); mChatModelConnection->invokeToModel([this, sipAddress]() { mChatModel->removeParticipant(sipAddress); });
}); });
mChatModelConnection->makeConnectToCore(&ChatCore::lSetParticipantsAddresses, [this](QStringList addresses) { mChatModelConnection->makeConnectToCore(&ChatCore::lSetParticipantsAddresses, [this](QStringList addresses) {
mChatModelConnection->invokeToModel([this, addresses]() { mChatModel->setParticipantAddresses(addresses); }); mChatModelConnection->invokeToModel([this, addresses]() { mChatModel->setParticipantAddresses(addresses); });
}); });
mChatModelConnection->makeConnectToCore(&ChatCore::lToggleParticipantAdminStatusAtIndex, [this](int index) { mChatModelConnection->makeConnectToCore(&ChatCore::lToggleParticipantAdminStatus, [this](QString sipAddress) {
mChatModelConnection->invokeToModel( mChatModelConnection->invokeToModel(
[this, index]() { mChatModel->toggleParticipantAdminStatusAtIndex(index); }); [this, sipAddress]() { mChatModel->toggleParticipantAdminStatus(sipAddress); });
}); });
mCoreModelConnection = SafeConnection<ChatCore, CoreModel>::create(me, CoreModel::getInstance()); mCoreModelConnection = SafeConnection<ChatCore, CoreModel>::create(me, CoreModel::getInstance());

View file

@ -192,9 +192,9 @@ signals:
void lSetMuted(bool muted); void lSetMuted(bool muted);
void lSetEphemeralLifetime(int time); void lSetEphemeralLifetime(int time);
void lSetSubject(QString subject); void lSetSubject(QString subject);
void lRemoveParticipantAtIndex(int index); void lRemoveParticipant(QString sipAddress);
void lSetParticipantsAddresses(QStringList addresses); void lSetParticipantsAddresses(QStringList addresses);
void lToggleParticipantAdminStatusAtIndex(int index); void lToggleParticipantAdminStatus(QString sipAddress);
private: private:
QString id; QString id;

View file

@ -221,14 +221,19 @@ void ChatModel::setSubject(QString subject) const {
return mMonitor->setSubject(Utils::appStringToCoreString(subject)); return mMonitor->setSubject(Utils::appStringToCoreString(subject));
} }
void ChatModel::removeParticipantAtIndex(int index) const { void ChatModel::removeParticipant(const QString &sipAddress) const {
auto participant = *std::next(mMonitor->getParticipants().begin(), index); if (!mMonitor) return;
mMonitor->removeParticipant(participant); auto addr = Utils::appStringToCoreString(sipAddress);
for (auto &p : mMonitor->getParticipants())
if (p && p->getAddress()->asStringUriOnly() == addr) return mMonitor->removeParticipant(p);
} }
void ChatModel::toggleParticipantAdminStatusAtIndex(int index) const { void ChatModel::toggleParticipantAdminStatus(const QString &sipAddress) const {
auto participant = *std::next(mMonitor->getParticipants().begin(), index); if (!mMonitor) return;
mMonitor->setParticipantAdminStatus(participant, !participant->isAdmin()); auto addr = Utils::appStringToCoreString(sipAddress);
for (auto &p : mMonitor->getParticipants())
if (p && p->getAddress()->asStringUriOnly() == addr)
return mMonitor->setParticipantAdminStatus(p, !p->isAdmin());
} }
void ChatModel::setParticipantAddresses(const QStringList &addresses) { void ChatModel::setParticipantAddresses(const QStringList &addresses) {

View file

@ -81,9 +81,9 @@ public:
void setMuted(bool muted); void setMuted(bool muted);
void setEphemeralLifetime(int time); void setEphemeralLifetime(int time);
void setSubject(QString subject) const; void setSubject(QString subject) const;
void removeParticipantAtIndex(int index) const; void removeParticipant(const QString &sipAddress) const;
void setParticipantAddresses(const QStringList &addresses); void setParticipantAddresses(const QStringList &addresses);
void toggleParticipantAdminStatusAtIndex(int index) const; void toggleParticipantAdminStatus(const QString &sipAddress) const;
signals: signals:
void historyDeleted(); void historyDeleted();

View file

@ -144,7 +144,7 @@ ColumnLayout {
icon.height: Utils.getSizeWithScreenRatio(32) icon.height: Utils.getSizeWithScreenRatio(32)
onClicked: { onClicked: {
detailOptions.close() detailOptions.close()
mainItem.chatGui.core.lToggleParticipantAdminStatusAtIndex(index) mainItem.chatGui.core.lToggleParticipantAdminStatus(participantGui.core.sipAddress)
} }
} }
IconLabelButton { IconLabelButton {
@ -181,7 +181,7 @@ ColumnLayout {
"", "",
function(confirmed) { function(confirmed) {
if (confirmed) { if (confirmed) {
mainItem.chatGui.core.lRemoveParticipantAtIndex(index) mainItem.chatGui.core.lRemoveParticipant(participantGui.core.sipAddress)
} }
}) })
} }