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
|
const contact = await window
|
||||||
.require('WAWebCollections')
|
.require('WAWebCollections')
|
||||||
.Contact.find(contactId);
|
.Contact.find(contactId);
|
||||||
const resolved = window
|
const lid = contact.id.isLid()
|
||||||
.require('WAWebBlockContactUtils')
|
? contact.id
|
||||||
.getContactToBlockOnlyUseIfNoAssociatedChat(
|
: window
|
||||||
contact,
|
.require('WAWebApiContact')
|
||||||
'ChatListBlock',
|
.getAlternateUserWid(contact.id);
|
||||||
);
|
const ContactToBlock = {
|
||||||
await window
|
id: lid,
|
||||||
.require('WAWebBlockContactAction')
|
isContactBlocked: false,
|
||||||
.blockContact({ contact: resolved });
|
phoneNumber: null,
|
||||||
|
};
|
||||||
|
await window.require('WAWebBlockContactAction').blockContact({
|
||||||
|
contact: ContactToBlock,
|
||||||
|
blockEntryPoint: 'ChatListBlock',
|
||||||
|
});
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
this.isBlocked = true;
|
this.isBlocked = true;
|
||||||
|
|
@ -181,18 +186,21 @@ class Contact extends Base {
|
||||||
if (this.isGroup) return false;
|
if (this.isGroup) return false;
|
||||||
|
|
||||||
await this.client.pupPage.evaluate(async (contactId) => {
|
await this.client.pupPage.evaluate(async (contactId) => {
|
||||||
const contact = await window
|
let contact = await window
|
||||||
.require('WAWebCollections')
|
.require('WAWebCollections')
|
||||||
.Contact.find(contactId);
|
.Contact.find(contactId);
|
||||||
const resolved = window
|
if (!contact.id.isLid()) {
|
||||||
.require('WAWebBlockContactUtils')
|
const lid = window
|
||||||
.getContactToBlockOnlyUseIfNoAssociatedChat(
|
.require('WAWebApiContact')
|
||||||
contact,
|
.getAlternateUserWid(contact.id);
|
||||||
'ChatListBlock',
|
|
||||||
);
|
contact = await window
|
||||||
|
.require('WAWebCollections')
|
||||||
|
.Contact.find(lid._serialized);
|
||||||
|
}
|
||||||
await window
|
await window
|
||||||
.require('WAWebBlockContactAction')
|
.require('WAWebBlockContactAction')
|
||||||
.unblockContact(resolved);
|
.unblockContact(contact, 'ChatListBlock');
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
this.isBlocked = false;
|
this.isBlocked = false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue