From d71bf7d1c2a6a52e8f530cce9c6cdb731d020246 Mon Sep 17 00:00:00 2001 From: Daffa Mumtaz Date: Fri, 22 Apr 2022 11:03:23 +0700 Subject: [PATCH] check if inline reply is supported & cleanup --- src/Main/MainWindow.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Main/MainWindow.js b/src/Main/MainWindow.js index 83e0254..6c95133 100644 --- a/src/Main/MainWindow.js +++ b/src/Main/MainWindow.js @@ -270,10 +270,13 @@ module.exports = class MainWindow extends BrowserWindow { (await this.whatsapp.getChatById(tag)).sendSeen(); }); - notif.addInlineReply('Reply', async (reply) => { - console.log('replied', reply); - (await this.whatsapp.getChatById(tag)).sendMessage(reply); - }); + const canReply = await Notify.supportsInlineReply(); + if(canReply) { + notif.addInlineReply('Reply', async (reply) => { + console.log('replied', reply); + (await this.whatsapp.getChatById(tag)).sendMessage(reply); + }); + } notif.show(); } @@ -286,14 +289,11 @@ module.exports = class MainWindow extends BrowserWindow { this.whatsapp = new Client(pieBrowser, this); this.whatsappReady = false; - this.whatsapp.on('ready', async () => { + this.whatsapp.on('ready', () => { console.log('Whatsapp client ready'); this.whatsappReady = true; this.webContents.send('ready', this._id); this.emit('ready'); - - const chats = await this.whatsapp.getChats(); - console.log(chats[0].id._serialized); }); this.whatsapp.on("change_battery", (batteryInfo) => {