diff --git a/src/WAConnection/4.Events.ts b/src/WAConnection/4.Events.ts index da4df18..dfee878 100644 --- a/src/WAConnection/4.Events.ts +++ b/src/WAConnection/4.Events.ts @@ -35,8 +35,8 @@ export class WAConnection extends Base { const chat = this.chats.get (user.jid) if (chat) { - chat.title = user.name || user.notify - this.emit ('chat-update', { jid: chat.jid, title: chat.title }) + chat.name = user.name || user.notify + 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)) } /** inserts an empty chat into the DB */ - protected async chatAdd (jid: string, title?: string) { + protected async chatAdd (jid: string, name?: string) { const chat: WAChat = { jid: jid, t: unixTimestampSeconds(), @@ -153,7 +153,7 @@ export class WAConnection extends Base { count: 0, modify_tag: '', spam: 'false', - title + name } await this.setProfilePicture (chat) this.chats.insert (chat) @@ -246,8 +246,8 @@ export class WAConnection extends Base { this.emit ('group-description-update', { jid, actor }) break case WA_MESSAGE_STUB_TYPE.GROUP_CHANGE_SUBJECT: - chat.title = message.messageStubParameters[0] - this.emit ('chat-update', { jid, title: chat.title }) + chat.name = message.messageStubParameters[0] + this.emit ('chat-update', { jid, name: chat.name }) break } } diff --git a/src/WAConnection/5.User.ts b/src/WAConnection/5.User.ts index 4ad5f0f..b5c07b6 100644 --- a/src/WAConnection/5.User.ts +++ b/src/WAConnection/5.User.ts @@ -94,7 +94,7 @@ export class WAConnection extends Base { async loadChats (count: number, before: number | null, searchString?: string) { let db = this.chats 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) await Promise.all ( diff --git a/src/WAConnection/8.Groups.ts b/src/WAConnection/8.Groups.ts index 5d65d26..06be771 100644 --- a/src/WAConnection/8.Groups.ts +++ b/src/WAConnection/8.Groups.ts @@ -70,12 +70,11 @@ export class WAConnection extends Base { */ groupUpdateSubject = async (jid: string, title: string) => { 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) - if (chat) { - chat.title = title - //this.emit ('chat-update', {jid, title}) - } + if (chat) chat.name = title + return response }