mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: add "strictNullChecks"
This commit is contained in:
@@ -114,9 +114,9 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||
{
|
||||
tag: 'read',
|
||||
attrs: {
|
||||
jid: fromMessage.remoteJid,
|
||||
jid: fromMessage.remoteJid!,
|
||||
count: count.toString(),
|
||||
index: fromMessage.id,
|
||||
index: fromMessage.id!,
|
||||
owner: fromMessage.fromMe ? 'true' : 'false'
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||
[ WAMetric.read, WAFlag.ignore ]
|
||||
)
|
||||
if(config.emitOwnEvents) {
|
||||
ev.emit('chats.update', [{ id: fromMessage.remoteJid, unreadCount: count < 0 ? -1 : 0 }])
|
||||
ev.emit('chats.update', [{ id: fromMessage.remoteJid!, unreadCount: count < 0 ? -1 : 0 }])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,10 +225,11 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||
})
|
||||
// User Profile Name Updates
|
||||
socketEvents.on('CB:Conn,pushname', json => {
|
||||
const { legacy: { user }, connection } = state
|
||||
if(connection === 'open' && json[1].pushname !== user.name) {
|
||||
user.name = json[1].pushname
|
||||
ev.emit('connection.update', { legacy: { ...state.legacy, user } })
|
||||
const { legacy, connection } = state
|
||||
const { user } = legacy!
|
||||
if(connection === 'open' && json[1].pushname !== user!.name) {
|
||||
user!.name = json[1].pushname
|
||||
ev.emit('connection.update', { legacy: { ...legacy!, user } })
|
||||
}
|
||||
})
|
||||
// read updates
|
||||
@@ -354,7 +355,7 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||
}
|
||||
))
|
||||
} else if('markRead' in modification) {
|
||||
const indexKey = getIndexKey(modification.lastMessages)
|
||||
const indexKey = getIndexKey(modification.lastMessages)!
|
||||
return chatRead(indexKey, modification.markRead ? 0 : -1)
|
||||
} else if('delete' in modification) {
|
||||
chatAttrs.type = 'delete'
|
||||
@@ -363,7 +364,7 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||
if('lastMessages' in modification) {
|
||||
const indexKey = getIndexKey(modification.lastMessages)
|
||||
if(indexKey) {
|
||||
chatAttrs.index = indexKey.id
|
||||
chatAttrs.index = indexKey.id!
|
||||
chatAttrs.owner = indexKey.fromMe ? 'true' : 'false'
|
||||
}
|
||||
}
|
||||
@@ -409,7 +410,7 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||
content: [
|
||||
{
|
||||
tag: 'presence',
|
||||
attrs: { type: type, to: toJid }
|
||||
attrs: { type: type, to: toJid! }
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -463,7 +464,7 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||
if(config.emitOwnEvents) {
|
||||
const user = { ...state.legacy!.user!, name }
|
||||
ev.emit('connection.update', { legacy: {
|
||||
...state.legacy, user
|
||||
...state.legacy!, user
|
||||
} })
|
||||
ev.emit('contacts.update', [{ id: user.id, name }])
|
||||
}
|
||||
@@ -493,11 +494,11 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||
const { eurl } = await this.setQuery ([query], [WAMetric.picture, 136], tag) as { eurl: string, status: number }
|
||||
|
||||
if(config.emitOwnEvents) {
|
||||
if(jid === user.id) {
|
||||
if(jid === user?.id) {
|
||||
user.imgUrl = eurl
|
||||
ev.emit('connection.update', {
|
||||
legacy: {
|
||||
...state.legacy,
|
||||
...state.legacy!,
|
||||
user
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user