From 8e8d8d57f0c40b4d5f5ed129b1317ff6cc4bbeb1 Mon Sep 17 00:00:00 2001 From: Edgard Date: Wed, 8 Dec 2021 21:41:43 -0300 Subject: [PATCH] feat: Added startRecording function and deprecated setChatState --- src/api/layers/sender.layer.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/api/layers/sender.layer.ts b/src/api/layers/sender.layer.ts index cd5b09848..d387f01a9 100644 --- a/src/api/layers/sender.layer.ts +++ b/src/api/layers/sender.layer.ts @@ -843,6 +843,33 @@ export class SenderLayer extends ListenerLayer { }); } + /** + * Starts recording ('Recording...' state) + * @category Chat + * @param chatId + */ + public async startRecording(to: string, duration?: number) { + return evaluateAndReturn( + this.page, + ({ to, duration }) => WPP.chat.markIsRecording(to, duration), + { + to, + duration, + } + ); + } + + /** + * Stops recording ('Recording...' state) + * @category Chat + * @param chatId + */ + public async stopRecoring(to: string) { + return evaluateAndReturn(this.page, ({ to }) => WPP.chat.markIsPaused(to), { + to, + }); + } + /** * Update your online presence * @category Chat @@ -914,9 +941,11 @@ export class SenderLayer extends ListenerLayer { /** * Sets the chat state + * Deprecated in favor of Use startTyping or startRecording functions * @category Chat * @param chatState * @param chatId + * @deprecated Deprecated in favor of Use startTyping or startRecording functions */ public async setChatState(chatId: string, chatState: ChatState) { return await evaluateAndReturn(