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

fix(groupinvite): prevent multiple groupinvites to the same group from showing up

fix #2305
This commit is contained in:
sudden6 2017-05-07 13:41:17 +02:00
parent c41f533818
commit 13029e3047
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
3 changed files with 14 additions and 3 deletions

View File

@ -114,9 +114,16 @@ void GroupInviteForm::show(ContentLayout* contentLayout)
* @param friendId Id of a friend that invited you
* @param type Type of the invitation - text or AV
* @param invite Information that invited person needs to see an invitation
* @return true if notification is needed, false otherwise
*/
void GroupInviteForm::addGroupInvite(int32_t friendId, uint8_t type, QByteArray invite)
bool GroupInviteForm::addGroupInvite(int32_t friendId, uint8_t type, QByteArray invite)
{
// supress duplicate invite messages
for (GroupInviteWidget* existing : invites) {
if (existing->getInviteInfo().getInvite() == invite) {
return false;
}
}
GroupInviteWidget* widget = new GroupInviteWidget(this, GroupInvite(friendId, type, invite));
scroll->widget()->layout()->addWidget(widget);
invites.append(widget);
@ -129,7 +136,9 @@ void GroupInviteForm::addGroupInvite(int32_t friendId, uint8_t type, QByteArray
[this](const GroupInvite& inviteInfo) { deleteInviteWidget(inviteInfo); });
if (isVisible()) {
emit groupInvitesSeen();
return false;
}
return true;
}
void GroupInviteForm::showEvent(QShowEvent* event)

View File

@ -46,7 +46,7 @@ public:
~GroupInviteForm();
void show(ContentLayout* contentLayout);
void addGroupInvite(int32_t friendId, uint8_t type, QByteArray invite);
bool addGroupInvite(int32_t friendId, uint8_t type, QByteArray invite);
bool isShown() const;
signals:

View File

@ -1565,10 +1565,12 @@ void Widget::onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray in
if (Settings::getInstance().getAutoGroupInvite(f->getPublicKey())) {
onGroupInviteAccepted(friendId, type, invite);
} else {
if (!groupInviteForm->addGroupInvite(friendId, type, invite)) {
return;
}
++unreadGroupInvites;
groupInvitesUpdate();
newMessageAlert(window(), isActiveWindow(), true, true);
groupInviteForm->addGroupInvite(friendId, type, invite);
}
} else {
qWarning() << "onGroupInviteReceived: Unknown groupchat type:" << type;