mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Better search for numbers + chat fix
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import * as QR from 'qrcode-terminal'
|
import * as QR from 'qrcode-terminal'
|
||||||
import { WAConnection as Base } from './3.Connect'
|
import { WAConnection as Base } from './3.Connect'
|
||||||
import { WAMessageStatusUpdate, WAMessage, WAContact, WAChat, WAMessageProto, WA_MESSAGE_STUB_TYPE, WA_MESSAGE_STATUS_TYPE, PresenceUpdate, BaileysEvent, DisconnectReason, WAOpenResult, Presence, AuthenticationCredentials, WAParticipantAction, WAGroupMetadata, WAUser, WANode } from './Constants'
|
import { WAMessageStatusUpdate, WAMessage, WAContact, WAChat, WAMessageProto, WA_MESSAGE_STUB_TYPE, WA_MESSAGE_STATUS_TYPE, PresenceUpdate, BaileysEvent, DisconnectReason, WAOpenResult, Presence, AuthenticationCredentials, WAParticipantAction, WAGroupMetadata, WAUser, WANode } from './Constants'
|
||||||
import { whatsappID, unixTimestampSeconds, isGroupID, GET_MESSAGE_ID, WA_MESSAGE_ID, waMessageKey, newMessagesDB, shallowChanges } from './Utils'
|
import { whatsappID, unixTimestampSeconds, isGroupID, GET_MESSAGE_ID, WA_MESSAGE_ID, waMessageKey, newMessagesDB, shallowChanges, toNumber } from './Utils'
|
||||||
import KeyedDB from '@adiwajshing/keyed-db'
|
import KeyedDB from '@adiwajshing/keyed-db'
|
||||||
import { Mutex } from './Mutex'
|
import { Mutex } from './Mutex'
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ export class WAConnection extends Base {
|
|||||||
}
|
}
|
||||||
// only update if it's an actual message
|
// only update if it's an actual message
|
||||||
if (message.message) {
|
if (message.message) {
|
||||||
this.chatUpdateTime (chat)
|
this.chatUpdateTime (chat, toNumber(message.messageTimestamp))
|
||||||
chatUpdate.t = chat.t
|
chatUpdate.t = chat.t
|
||||||
}
|
}
|
||||||
chatUpdate.messages = newMessagesDB([ message ])
|
chatUpdate.messages = newMessagesDB([ message ])
|
||||||
@@ -473,7 +473,7 @@ export class WAConnection extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected chatUpdateTime = chat => this.chats.updateKey (chat, c => c.t = unixTimestampSeconds())
|
protected chatUpdateTime = (chat, stamp: number) => this.chats.updateKey (chat, c => c.t = stamp)
|
||||||
/** sets the profile picture of a chat */
|
/** sets the profile picture of a chat */
|
||||||
protected async setProfilePicture (chat: WAChat) {
|
protected async setProfilePicture (chat: WAChat) {
|
||||||
chat.imgUrl = await this.getProfilePicture (chat.jid).catch (err => '')
|
chat.imgUrl = await this.getProfilePicture (chat.jid).catch (err => '')
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export class WAConnection extends Base {
|
|||||||
const searchString = options.searchString?.toLowerCase()
|
const searchString = options.searchString?.toLowerCase()
|
||||||
const chats = this.chats.paginated (before, count, options && (chat => (
|
const chats = this.chats.paginated (before, count, options && (chat => (
|
||||||
(typeof options?.custom !== 'function' || options?.custom(chat)) &&
|
(typeof options?.custom !== 'function' || options?.custom(chat)) &&
|
||||||
(typeof searchString === 'undefined' || chat.name?.toLowerCase().includes (searchString) || chat.jid?.startsWith(searchString))
|
(typeof searchString === 'undefined' || chat.name?.toLowerCase().includes (searchString) || chat.jid?.includes(searchString))
|
||||||
)))
|
)))
|
||||||
let loadPP = this.loadProfilePicturesForChatsAutomatically
|
let loadPP = this.loadProfilePicturesForChatsAutomatically
|
||||||
if (typeof options.loadProfilePicture !== 'undefined') loadPP = options.loadProfilePicture
|
if (typeof options.loadProfilePicture !== 'undefined') loadPP = options.loadProfilePicture
|
||||||
|
|||||||
Reference in New Issue
Block a user