From 3534221e11a8a4f28bb97b1435a728d8c0e063ee Mon Sep 17 00:00:00 2001 From: rafaelwedbiz <30352114+rafaelwedbiz@users.noreply.github.com> Date: Wed, 29 Dec 2021 03:30:35 -0300 Subject: [PATCH] Fix Played Status (message update event) (#1089) * Fix Played Status * Update messages-recv.ts Co-authored-by: Adhiraj Singh --- src/Socket/messages-recv.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 16cc761..dc800e0 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -7,16 +7,14 @@ import { KEY_BUNDLE_TYPE } from "../Defaults" import { makeChatsSocket } from "./chats" import { extractGroupMetadata } from "./groups" -const getStatusFromReceiptType = (type: string | undefined) => { - if(type === 'read' || type === 'read-self') { - return proto.WebMessageInfo.WebMessageInfoStatus.READ - } - if(typeof type === 'undefined') { - return proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK - } - return undefined +const STATUS_MAP: { [_: string]: proto.WebMessageInfo.WebMessageInfoStatus } = { + 'played': proto.WebMessageInfo.WebMessageInfoStatus.PLAYED, + 'read': proto.WebMessageInfo.WebMessageInfoStatus.READ, + 'read-self': proto.WebMessageInfo.WebMessageInfoStatus.READ } +const getStatusFromReceiptType = (type: string | undefined) => STATUS_MAP[type] + export const makeMessagesRecvSocket = (config: SocketConfig) => { const { logger } = config const sock = makeChatsSocket(config) @@ -606,4 +604,4 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { }) return { ...sock, processMessage, sendMessageAck } -} \ No newline at end of file +}