Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions src/structures/Contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,20 @@ class Contact extends Base {
const contact = await window
.require('WAWebCollections')
.Contact.find(contactId);
const resolved = window
.require('WAWebBlockContactUtils')
.getContactToBlockOnlyUseIfNoAssociatedChat(
contact,
'ChatListBlock',
);
await window
.require('WAWebBlockContactAction')
.blockContact({ contact: resolved });
const lid = contact.id.isLid()
? contact.id
: window
.require('WAWebApiContact')
.getAlternateUserWid(contact.id);
const ContactToBlock = {
id: lid,
isContactBlocked: false,
phoneNumber: null,
};
await window.require('WAWebBlockContactAction').blockContact({
contact: ContactToBlock,
blockEntryPoint: 'ChatListBlock',
});
}, this.id._serialized);

this.isBlocked = true;
Expand All @@ -181,18 +186,21 @@ class Contact extends Base {
if (this.isGroup) return false;

await this.client.pupPage.evaluate(async (contactId) => {
const contact = await window
let contact = await window
.require('WAWebCollections')
.Contact.find(contactId);
const resolved = window
.require('WAWebBlockContactUtils')
.getContactToBlockOnlyUseIfNoAssociatedChat(
contact,
'ChatListBlock',
);
if (!contact.id.isLid()) {
const lid = window
.require('WAWebApiContact')
.getAlternateUserWid(contact.id);

contact = await window
.require('WAWebCollections')
.Contact.find(lid._serialized);
}
await window
.require('WAWebBlockContactAction')
.unblockContact(resolved);
.unblockContact(contact, 'ChatListBlock');
}, this.id._serialized);

this.isBlocked = false;
Expand Down
Loading