proposal: detect desktop and fix device identification using message

This commit is contained in:
Andres Aya
2023-10-19 15:21:38 -05:00
parent e24947e55a
commit 18681c995b

View File

@@ -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<WAMessage, 'userReceipt'>, receipt: MessageUserReceipt) => {