fix undefined error on messages fetch

This commit is contained in:
Adhiraj Singh
2021-07-18 22:12:35 +05:30
parent 8a5e6489c0
commit cd127dbca9

View File

@@ -202,8 +202,12 @@ export default(
let messages: WAMessage[]
if(list && mode === 'before' && (!cursorKey || cursorValue)) {
const msgIdx = list.array.findIndex(m => m.key.id === cursorKey.id)
messages = list.array.slice(0, msgIdx)
if(cursorValue) {
const msgIdx = list.array.findIndex(m => m.key.id === cursorKey.id)
messages = list.array.slice(0, msgIdx)
} else {
messages = list.array
}
const diff = count - messages.length
if (diff < 0) {