This commit is contained in:
Adhiraj
2020-08-23 22:41:36 +05:30
parent c44413538b
commit a82d5bb1fe
3 changed files with 11 additions and 12 deletions

View File

@@ -35,8 +35,8 @@ export class WAConnection extends Base {
const chat = this.chats.get (user.jid) const chat = this.chats.get (user.jid)
if (chat) { if (chat) {
chat.title = user.name || user.notify chat.name = user.name || user.notify
this.emit ('chat-update', { jid: chat.jid, title: chat.title }) this.emit ('chat-update', { jid: chat.jid, name: chat.name })
} }
} }
}) })
@@ -145,7 +145,7 @@ export class WAConnection extends Base {
this.registerCallback('Presence', json => this.emit('user-presence-update', json[1] as PresenceUpdate)) this.registerCallback('Presence', json => this.emit('user-presence-update', json[1] as PresenceUpdate))
} }
/** inserts an empty chat into the DB */ /** inserts an empty chat into the DB */
protected async chatAdd (jid: string, title?: string) { protected async chatAdd (jid: string, name?: string) {
const chat: WAChat = { const chat: WAChat = {
jid: jid, jid: jid,
t: unixTimestampSeconds(), t: unixTimestampSeconds(),
@@ -153,7 +153,7 @@ export class WAConnection extends Base {
count: 0, count: 0,
modify_tag: '', modify_tag: '',
spam: 'false', spam: 'false',
title name
} }
await this.setProfilePicture (chat) await this.setProfilePicture (chat)
this.chats.insert (chat) this.chats.insert (chat)
@@ -246,8 +246,8 @@ export class WAConnection extends Base {
this.emit ('group-description-update', { jid, actor }) this.emit ('group-description-update', { jid, actor })
break break
case WA_MESSAGE_STUB_TYPE.GROUP_CHANGE_SUBJECT: case WA_MESSAGE_STUB_TYPE.GROUP_CHANGE_SUBJECT:
chat.title = message.messageStubParameters[0] chat.name = message.messageStubParameters[0]
this.emit ('chat-update', { jid, title: chat.title }) this.emit ('chat-update', { jid, name: chat.name })
break break
} }
} }

View File

@@ -94,7 +94,7 @@ export class WAConnection extends Base {
async loadChats (count: number, before: number | null, searchString?: string) { async loadChats (count: number, before: number | null, searchString?: string) {
let db = this.chats let db = this.chats
if (searchString) { if (searchString) {
db = db.filter (value => value.title?.includes (searchString) || value.jid?.startsWith(searchString)) db = db.filter (value => value.name?.includes (searchString) || value.jid?.startsWith(searchString))
} }
const chats = db.paginated (before, count) const chats = db.paginated (before, count)
await Promise.all ( await Promise.all (

View File

@@ -70,12 +70,11 @@ export class WAConnection extends Base {
*/ */
groupUpdateSubject = async (jid: string, title: string) => { groupUpdateSubject = async (jid: string, title: string) => {
const chat = this.chats.get (jid) const chat = this.chats.get (jid)
if (chat?.title === title) throw new Error ('redundant change') if (chat?.name === title) throw new Error ('redundant change')
const response = await this.groupQuery('subject', jid, title) const response = await this.groupQuery('subject', jid, title)
if (chat) { if (chat) chat.name = title
chat.title = title
//this.emit ('chat-update', {jid, title})
}
return response return response
} }