Skip to content

Commit

Permalink
fix: Fixed block/unblock contact (fix #498)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Oct 2, 2021
1 parent fc65307 commit 832fceb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
12 changes: 8 additions & 4 deletions src/api/layers/controls.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ export class ControlsLayer extends UILayer {
* @returns boolean
*/
public async unblockContact(contactId: string) {
return evaluateAndReturn(
await evaluateAndReturn(
this.page,
(contactId) => WAPI.unblockContact(contactId),
(contactId) => WPP.blocklist.unblockContact(contactId),
contactId
);

return true;
}

/**
Expand All @@ -46,11 +48,13 @@ export class ControlsLayer extends UILayer {
* @returns boolean
*/
public async blockContact(contactId: string) {
return evaluateAndReturn(
await evaluateAndReturn(
this.page,
(contactId) => WAPI.blockContact(contactId),
(contactId) => WPP.blocklist.blockContact(contactId),
contactId
);

return true;
}

/**
Expand Down
12 changes: 2 additions & 10 deletions src/lib/wapi/functions/block-contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
*/

export async function blockContact(_id) {
if (!_id) {
return false;
}
const __contact = window.Store.Contact.get(_id);
if (__contact !== undefined) {
await Store.Block.blockContact(__contact);
return true;
} else {
return false;
}
await WPP.blocklist.blockContact(_id);
return true;
}
12 changes: 2 additions & 10 deletions src/lib/wapi/functions/unblock-contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
*/

export async function unblockContact(_id) {
if (!_id) {
return false;
}
const __contact = window.Store.Contact.get(_id);
if (__contact !== undefined) {
await Store.Block.unblockContact(__contact);
return true;
} else {
return false;
}
await WPP.blocklist.unblockContact(_id);
return true;
}

0 comments on commit 832fceb

Please sign in to comment.