Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(groupinvite): prevent multiple groupinvites to the same group fro…
Browse files Browse the repository at this point in the history
…m showing up

fix #2305
  • Loading branch information
sudden6 committed May 7, 2017
1 parent c41f533 commit 13029e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/widget/form/groupinviteform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/widget/form/groupinviteform.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GroupInviteForm : public QWidget
~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:
Expand Down
4 changes: 3 additions & 1 deletion src/widget/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 13029e3

Please sign in to comment.