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 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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user