Skip to content

Commit

Permalink
fix: Fixed deleteChat method for multidevice (fix #586)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Oct 20, 2021
1 parent bfc63d2 commit 1d1e4a1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"webpack-cli": "^4.9.1"
},
"dependencies": {
"@wppconnect/wa-js": "^1.0.6",
"@wppconnect/wa-js": "^1.0.7",
"@wppconnect/wa-version": "^1.1.15",
"atob": "^2.1.2",
"axios": "^0.23.0",
Expand Down
2 changes: 1 addition & 1 deletion src/api/helpers/download-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function downloadFileToBase64(
}

try {
const response = await axios.get(_path, {
const response = await axios.get<any>(_path, {
responseType: 'arraybuffer',
});

Expand Down
5 changes: 3 additions & 2 deletions src/api/layers/controls.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ export class ControlsLayer extends UILayer {
* @returns boolean
*/
public async deleteChat(chatId: string) {
return evaluateAndReturn(
const result = await evaluateAndReturn(
this.page,
(chatId) => WAPI.deleteConversation(chatId),
(chatId) => WPP.chat.delete(chatId),
chatId
);
return result.status === 200;
}

/**
Expand Down
27 changes: 2 additions & 25 deletions src/lib/wapi/functions/delete-conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,7 @@
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
*/

export function deleteConversation(chatId, done) {
let userId = new window.Store.UserConstructor(chatId, {
intentionallyUsePrivateConstructor: true,
});
let conversation = WAPI.getChat(userId);

if (!conversation) {
if (done !== undefined) {
done(false);
}
return false;
}

window.Store.sendDelete(conversation, false)
.then(() => {
if (done !== undefined) {
done(true);
}
})
.catch(() => {
if (done !== undefined) {
done(false);
}
});

export function deleteConversation(chatId) {
WPP.chat.delete(chatId);
return true;
}

0 comments on commit 1d1e4a1

Please sign in to comment.