1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(group): remove redundant updatePeer API

This commit is contained in:
Anthony Bilinski 2019-05-14 16:40:41 -07:00
parent 6801298e96
commit 08839b7052
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
6 changed files with 8 additions and 15 deletions

View File

@ -576,11 +576,13 @@ void Core::onGroupPeerListChange(Tox*, uint32_t groupId, void* vCore)
}
void Core::onGroupPeerNameChange(Tox*, uint32_t groupId, uint32_t peerId, const uint8_t* name,
size_t length, void* core)
size_t length, void* vCore)
{
const auto newName = ToxString(name, length).getQString();
qDebug() << QString("Group %1, Peer %2, name changed to %3").arg(groupId).arg(peerId).arg(newName);
emit static_cast<Core*>(core)->groupPeerNameChanged(groupId, peerId, newName);
auto* core = static_cast<Core*>(vCore);
auto peerPk = core->getGroupPeerPk(groupId, peerId);
emit core->groupPeerNameChanged(groupId, peerPk, newName);
}
void Core::onGroupTitleChange(Tox*, uint32_t groupId, uint32_t peerId, const uint8_t* cTitle,

View File

@ -169,7 +169,7 @@ signals:
void groupMessageReceived(int groupnumber, int peernumber, const QString& message, bool isAction);
void groupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
void groupPeerlistChanged(int groupnumber);
void groupPeerNameChanged(int groupnumber, int peernumber, const QString& newName);
void groupPeerNameChanged(int groupnumber, const ToxPk& peerPk, const QString& newName);
void groupTitleChanged(int groupnumber, const QString& author, const QString& title);
void groupPeerAudioPlaying(int groupnumber, ToxPk peerPk);
void groupSentFailed(int groupId);

View File

@ -47,14 +47,6 @@ Group::Group(int groupId, const GroupId persistentGroupId, const QString& name,
regeneratePeerList();
}
void Group::updatePeer(int peerId, QString name)
{
ToxPk peerKey = Core::getInstance()->getGroupPeerPk(groupId, peerId);
toxpks[peerKey] = name;
qDebug() << "name change: " + name;
emit userListChanged(persistentGroupId, toxpks);
}
void Group::setName(const QString& newTitle)
{
const QString shortTitle = newTitle.left(MAX_GROUP_TITLE_LENGTH);

View File

@ -49,7 +49,6 @@ public:
void setMentionedFlag(bool f);
bool getMentionedFlag() const;
void updatePeer(int peerId, QString newName);
void updateUsername(ToxPk pk, const QString newName);
void setName(const QString& newTitle) override;
void setTitle(const QString& author, const QString& newTitle);

View File

@ -1772,7 +1772,7 @@ void Widget::onGroupPeerlistChanged(uint32_t groupnumber)
g->regeneratePeerList();
}
void Widget::onGroupPeerNameChanged(uint32_t groupnumber, int peernumber, const QString& newName)
void Widget::onGroupPeerNameChanged(uint32_t groupnumber, const ToxPk& peerPk, const QString& newName)
{
const GroupId& groupId = GroupList::id2Key(groupnumber);
Group* g = GroupList::findGroup(groupId);
@ -1783,7 +1783,7 @@ void Widget::onGroupPeerNameChanged(uint32_t groupnumber, int peernumber, const
setName = tr("<Empty>", "Placeholder when someone's name in a group chat is empty");
}
g->updatePeer(peernumber, setName);
g->updateUsername(peerPk, newName);
}
void Widget::onGroupTitleChanged(uint32_t groupnumber, const QString& author, const QString& title)

View File

@ -174,7 +174,7 @@ public slots:
void onGroupInviteAccepted(const GroupInvite& inviteInfo);
void onGroupMessageReceived(int groupnumber, int peernumber, const QString& message, bool isAction);
void onGroupPeerlistChanged(uint32_t groupnumber);
void onGroupPeerNameChanged(uint32_t groupnumber, int peernumber, const QString& newName);
void onGroupPeerNameChanged(uint32_t groupnumber, const ToxPk& peerPk, const QString& newName);
void onGroupTitleChanged(uint32_t groupnumber, const QString& author, const QString& title);
void titleChangedByUser(const GroupId& groupId, const QString& title);
void onGroupPeerAudioPlaying(int groupnumber, ToxPk peerPk);