potential fix for QR scan. the server may expect these messages to be sent on reconnect after scan (#959)

* potential fix for QR scan. the server may expect these messages to be sent on reconnect after scan.

* refactor: extract dictionary reduce code into utility

* refactor: convert the props + abt send req to somewhat useful query

Co-authored-by: Adhiraj Singh <adhirajsingh1001@gmail.com>
This commit is contained in:
HUGEIT
2021-12-03 14:10:26 +01:00
committed by GitHub
parent d9cfed64ff
commit 903871d180
3 changed files with 67 additions and 10 deletions

View File

@@ -308,5 +308,16 @@ export const assertNodeErrorFree = (node: BinaryNode) => {
}
}
export const reduceBinaryNodeToDictionary = (node: BinaryNode, tag: string) => {
const nodes = getBinaryNodeChildren(node, tag)
const dict = nodes.reduce(
(dict, { attrs }) => {
dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value
return dict
}, { } as { [_: string]: string }
)
return dict
}
export * from './jid-utils'
export { Binary } from '../../WABinary/Binary'