[feat]: add/edit/remove contacts (#1172)

* add/edit/remove contacts

* use proto type in contact action

---------

Co-authored-by: canove <cassio@economicros.com.br>
This commit is contained in:
vini
2025-07-09 16:01:20 -03:00
committed by GitHub
parent 31cb8d78a6
commit 19124426b2
3 changed files with 37 additions and 0 deletions
+26
View File
@@ -858,6 +858,30 @@ export const makeChatsSocket = (config: SocketConfig) => {
)
}
/**
* Add or Edit Contact
*/
const addOrEditContact = (jid: string, contact: proto.SyncActionValue.IContactAction) => {
return chatModify(
{
contact
},
jid
)
}
/**
* Remove Contact
*/
const removeContact = (jid: string) => {
return chatModify(
{
contact: null
},
jid
)
}
/**
* Adds label
*/
@@ -1087,6 +1111,8 @@ export const makeChatsSocket = (config: SocketConfig) => {
resyncAppState,
chatModify,
cleanDirtyBits,
addOrEditContact,
removeContact,
addLabel,
addChatLabel,
removeChatLabel,
+1
View File
@@ -110,6 +110,7 @@ export type ChatModification =
lastMessages: LastMessageList
}
| { delete: true; lastMessages: LastMessageList }
| { contact: proto.SyncActionValue.IContactAction | null }
// Label
| { addLabel: LabelActionBody }
// Label assosiation
+10
View File
@@ -605,6 +605,16 @@ export const chatModificationToAppPatch = (mod: ChatModification, jid: string) =
apiVersion: 5,
operation: OP.SET
}
} else if ('contact' in mod) {
patch = {
syncAction: {
contactAction: mod.contact || {}
},
index: ['contact', jid],
type: 'critical_unblock_low',
apiVersion: 2,
operation: mod.contact ? OP.SET : OP.REMOVE
}
} else if ('star' in mod) {
const key = mod.star.messages[0]
patch = {