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 e57307f47d
commit ca452efe80
5 changed files with 21 additions and 16 deletions

View file

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

View file

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

View file

@ -227,14 +227,19 @@ void ChatModel::setSubject(QString subject) const {
return mMonitor->setSubject(Utils::appStringToCoreString(subject));
}
void ChatModel::removeParticipantAtIndex(int index) const {
auto participant = *std::next(mMonitor->getParticipants().begin(), index);
mMonitor->removeParticipant(participant);
void ChatModel::removeParticipant(const QString &sipAddress) const {
if (!mMonitor) return;
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 {
auto participant = *std::next(mMonitor->getParticipants().begin(), index);
mMonitor->setParticipantAdminStatus(participant, !participant->isAdmin());
void ChatModel::toggleParticipantAdminStatus(const QString &sipAddress) const {
if (!mMonitor) return;
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) {

View file

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

View file

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