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:
parent
c41f533818
commit
13029e3047
|
@ -114,9 +114,16 @@ void GroupInviteForm::show(ContentLayout* contentLayout)
|
||||||
* @param friendId Id of a friend that invited you
|
* @param friendId Id of a friend that invited you
|
||||||
* @param type Type of the invitation - text or AV
|
* @param type Type of the invitation - text or AV
|
||||||
* @param invite Information that invited person needs to see an invitation
|
* @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));
|
GroupInviteWidget* widget = new GroupInviteWidget(this, GroupInvite(friendId, type, invite));
|
||||||
scroll->widget()->layout()->addWidget(widget);
|
scroll->widget()->layout()->addWidget(widget);
|
||||||
invites.append(widget);
|
invites.append(widget);
|
||||||
|
@ -129,7 +136,9 @@ void GroupInviteForm::addGroupInvite(int32_t friendId, uint8_t type, QByteArray
|
||||||
[this](const GroupInvite& inviteInfo) { deleteInviteWidget(inviteInfo); });
|
[this](const GroupInvite& inviteInfo) { deleteInviteWidget(inviteInfo); });
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
emit groupInvitesSeen();
|
emit groupInvitesSeen();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupInviteForm::showEvent(QShowEvent* event)
|
void GroupInviteForm::showEvent(QShowEvent* event)
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
~GroupInviteForm();
|
~GroupInviteForm();
|
||||||
|
|
||||||
void show(ContentLayout* contentLayout);
|
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;
|
bool isShown() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -1565,10 +1565,12 @@ void Widget::onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray in
|
||||||
if (Settings::getInstance().getAutoGroupInvite(f->getPublicKey())) {
|
if (Settings::getInstance().getAutoGroupInvite(f->getPublicKey())) {
|
||||||
onGroupInviteAccepted(friendId, type, invite);
|
onGroupInviteAccepted(friendId, type, invite);
|
||||||
} else {
|
} else {
|
||||||
|
if (!groupInviteForm->addGroupInvite(friendId, type, invite)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
++unreadGroupInvites;
|
++unreadGroupInvites;
|
||||||
groupInvitesUpdate();
|
groupInvitesUpdate();
|
||||||
newMessageAlert(window(), isActiveWindow(), true, true);
|
newMessageAlert(window(), isActiveWindow(), true, true);
|
||||||
groupInviteForm->addGroupInvite(friendId, type, invite);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "onGroupInviteReceived: Unknown groupchat type:" << type;
|
qWarning() << "onGroupInviteReceived: Unknown groupchat type:" << type;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user