Skip to content

Commit

Permalink
fix: Migrate archiveChat and pinChat methods to WA-JS
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed May 28, 2022
1 parent b7b8372 commit cee7e1c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/api/layers/controls.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class ControlsLayer extends UILayer {
public async archiveChat(chatId: string, option: boolean = true) {
return evaluateAndReturn(
this.page,
({ chatId, option }) => WAPI.archiveChat(chatId, option),
({ chatId, option }) => WPP.chat.archive(chatId, option),
{ chatId, option }
);
}
Expand All @@ -111,17 +111,19 @@ export class ControlsLayer extends UILayer {
* @returns object
*/
public async pinChat(chatId: string, option: boolean, nonExistent?: boolean) {
const result = await evaluateAndReturn(
if (nonExistent) {
await evaluateAndReturn(
this.page,
({ chatId }) => WPP.chat.find(chatId),
{ chatId }
);
}

return await evaluateAndReturn(
this.page,
({ chatId, option, nonExistent }) => {
return WAPI.pinChat(chatId, option, nonExistent);
},
{ chatId, option, nonExistent }
({ chatId, option }) => WPP.chat.pin(chatId, option),
{ chatId, option }
);
if (result['erro'] == true) {
throw result;
}
return result;
}

/**
Expand Down

0 comments on commit cee7e1c

Please sign in to comment.