mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
patch messages.update
This commit is contained in:
@@ -131,9 +131,9 @@ export default(
|
||||
}
|
||||
})
|
||||
ev.on('messages.update', updates => {
|
||||
for(const update of updates) {
|
||||
const list = assertMessageList(update.key.remoteJid)
|
||||
const result = list.updateAssign(update)
|
||||
for(const { update, key } of updates) {
|
||||
const list = assertMessageList(key.remoteJid)
|
||||
const result = list.updateAssign(key.id, update)
|
||||
if(!result) {
|
||||
logger.debug({ update }, `got update for non-existent message`)
|
||||
}
|
||||
@@ -201,8 +201,8 @@ export default(
|
||||
const cursorValue = cursorKey ? list.get(cursorKey.id) : undefined
|
||||
|
||||
let messages: WAMessage[]
|
||||
if(messages && mode ==='before' && (!cursorKey || cursorValue)) {
|
||||
const msgIdx = messages.findIndex(m => m.key.id === cursorKey.id)
|
||||
if(list && mode === 'before' && (!cursorKey || cursorValue)) {
|
||||
const msgIdx = list.array.findIndex(m => m.key.id === cursorKey.id)
|
||||
messages = list.array.slice(0, msgIdx)
|
||||
|
||||
const diff = count - messages.length
|
||||
|
||||
@@ -46,10 +46,12 @@ const makeOrderedDictionary = function<T>(idGetter: (item: T) => string) {
|
||||
upsert,
|
||||
update,
|
||||
remove,
|
||||
updateAssign: (update: Partial<T>) => {
|
||||
const item = get(idGetter(update as any))
|
||||
updateAssign: (id: string, update: Partial<T>) => {
|
||||
const item = get(id)
|
||||
if(item) {
|
||||
Object.assign(item, update)
|
||||
delete dict[id]
|
||||
dict[id] = item
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user