feat: send presence update when name changed

This commit is contained in:
Adhiraj Singh
2022-04-08 23:29:48 +05:30
parent 060c838707
commit f1b64c3c35
2 changed files with 8 additions and 2 deletions

View File

@@ -466,6 +466,10 @@ export const makeChatsSocket = (config: SocketConfig) => {
const processSyncActionsLocal = (actions: ChatMutation[]) => {
const events = processSyncActions(actions, authState.creds.me!, logger)
emitEventsFromMap(events)
// resend available presence to update name on servers
if(events['creds.update']?.me?.name) {
sendPresenceUpdate('available')
}
}
const appPatch = async(patchCreate: WAPatchCreate) => {

View File

@@ -583,8 +583,10 @@ export const processSyncActions = (
name: action.contactAction!.fullName
}
} else if(action?.pushNameSetting) {
map['creds.update'] = map['creds.update'] || { }
map['creds.update'].me = { ...me, name: action?.pushNameSetting?.name! }
if(me?.name !== action?.pushNameSetting) {
map['creds.update'] = map['creds.update'] || { }
map['creds.update'].me = { ...me, name: action?.pushNameSetting?.name! }
}
} else if(action?.pinAction) {
update.pin = action.pinAction?.pinned ? toNumber(action.timestamp) : undefined
} else if(action?.unarchiveChatsSetting) {