From 18681c995b12fb16c47fefb139fbc303dc240132 Mon Sep 17 00:00:00 2001 From: Andres Aya Date: Thu, 19 Oct 2023 15:21:38 -0500 Subject: [PATCH] proposal: detect desktop and fix device identification using message --- src/Utils/messages.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Utils/messages.ts b/src/Utils/messages.ts index 0ed8224..489cadf 100644 --- a/src/Utils/messages.ts +++ b/src/Utils/messages.ts @@ -732,10 +732,7 @@ export const extractMessageContent = (content: WAMessageContent | undefined | nu /** * Returns the device predicted by message ID */ -export const getDevice = (id: string) => { - const deviceType = id.length > 21 ? 'android' : id.substring(0, 2) === '3A' ? 'ios' : 'web' - return deviceType -} +export const getDevice = (id: string) => /^3A/.test(id) ? 'ios' : /^3E/.test(id) ? 'web' : /^.{21}/.test(id) ? 'android' : /^.{18}/.test(id) ? 'desktop' : 'unknown' /** Upserts a receipt in the message */ export const updateMessageWithReceipt = (msg: Pick, receipt: MessageUserReceipt) => {