fix: block unblock contact (#201753)
* Fix Block and UnBlock Contact * Update Contact.js
This commit is contained in:
parent
f935b50011
commit
f7e4d3d0fc
1 changed files with 25 additions and 17 deletions
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue