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

fix(core): update group peerLists on local changes

This commit is contained in:
Monsterovich 2018-12-26 18:05:03 +02:00
parent feee0e767f
commit 01f79b0d08
7 changed files with 30 additions and 1 deletions

View File

@ -84,6 +84,14 @@ void Friend::setAlias(const QString& alias)
if (oldDisplayed != newDisplayed) {
emit displayedNameChanged(newDisplayed);
}
for (Group* g : GroupList::getAllGroups()) {
if (userAlias.isEmpty()) {
g->updateUsername(friendPk, userName);
continue;
}
g->updateUsername(friendPk, userAlias);
}
}
void Friend::setStatusMessage(const QString& message)

View File

@ -119,6 +119,12 @@ void Group::regeneratePeerList()
emit userListChanged(groupId, toxpks);
}
void Group::updateUsername(ToxPk pk, const QString newName)
{
toxpks[pk] = newName;
emit userListChanged(groupId, toxpks);
}
bool Group::isAvGroupchat() const
{
return avGroupchat;

View File

@ -47,6 +47,7 @@ public:
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);
QString getName() const;

View File

@ -213,6 +213,7 @@ void Nexus::showMainGUI()
connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged);
connect(core, &Core::messageSentResult, widget, &Widget::onMessageSendResult);
connect(core, &Core::groupSentFailed, widget, &Widget::onGroupSendFailed);
connect(core, &Core::usernameSet, widget, &Widget::refreshPeerListsLocal);
connect(widget, &Widget::statusSet, core, &Core::setStatus);
connect(widget, &Widget::friendRequested, core, &Core::requestFriendship);

View File

@ -337,7 +337,12 @@ void GroupChatForm::sendJoinLeaveMessages()
addSystemInfoMessage(tr("%1 has joined the group").arg(name), ChatMessage::INFO, QDateTime::currentDateTime());
}
else {
if (groupLast[peerPk] != name && peers.value(peerPk) == name) {
Friend *f = FriendList::findFriend(peerPk);
if (groupLast[peerPk] != name
&& peers.value(peerPk) == name
&& peerPk != Core::getInstance()->getSelfPublicKey() // ignore myself
&& !(f != nullptr && f->hasAlias()) // ignore friends with aliases
) {
addSystemInfoMessage(tr("%1 is now known as %2").arg(groupLast[peerPk], name), ChatMessage::INFO, QDateTime::currentDateTime());
groupLast[peerPk] = name;
}

View File

@ -2503,3 +2503,10 @@ void Widget::focusChatInput()
}
}
}
void Widget::refreshPeerListsLocal(const QString &username)
{
for (Group* g : GroupList::getAllGroups()) {
g->updateUsername(Core::getInstance()->getSelfPublicKey(), username);
}
}

View File

@ -182,6 +182,7 @@ public slots:
void onFriendDialogShown(const Friend* f);
void onGroupDialogShown(Group* g);
void toggleFullscreen();
void refreshPeerListsLocal(const QString &username);
signals:
void friendRequestAccepted(const ToxPk& friendPk);