@arcaelas/whatsapp 6.1.2 → 6.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -595,10 +595,16 @@ class WhatsApp {
595
595
  if (doc.lid) {
596
596
  await this.engine.set(`/lid/${doc.lid}`, (0, store_1.serialize)(doc.id));
597
597
  }
598
- if (!current) {
598
+ // Una ficha que existía vacía y ahora tiene nombre es un cambio que el consumidor
599
+ // necesita: sin avisar, quien memorice el contacto sigue mostrando el número.
600
+ // A card that existed empty and now has a name is a change the consumer needs: without
601
+ // notifying, whoever memoized the contact keeps showing the bare number.
602
+ const changed = current && ['lid', 'name', 'notify', 'verified_name', 'img_url', 'status'].some((key) => current[key] !== doc[key]);
603
+ if (!current || changed) {
599
604
  const person = new this.Contact(doc);
600
605
  const cached_chat = (0, store_1.deserialize)(await this.engine.get(`/chat/${doc.id}`));
601
- this.emit('contact:created', person, new this.Chat(cached_chat ?? { id: doc.id, name: person.name }), this);
606
+ const chat = new this.Chat(cached_chat ?? { id: doc.id, name: person.name });
607
+ this.emit(current ? 'contact:updated' : 'contact:created', person, chat, this);
602
608
  }
603
609
  }
604
610
  /** @internal */
@@ -556,10 +556,16 @@ export class WhatsApp {
556
556
  if (doc.lid) {
557
557
  await this.engine.set(`/lid/${doc.lid}`, serialize(doc.id));
558
558
  }
559
- if (!current) {
559
+ // Una ficha que existía vacía y ahora tiene nombre es un cambio que el consumidor
560
+ // necesita: sin avisar, quien memorice el contacto sigue mostrando el número.
561
+ // A card that existed empty and now has a name is a change the consumer needs: without
562
+ // notifying, whoever memoized the contact keeps showing the bare number.
563
+ const changed = current && ['lid', 'name', 'notify', 'verified_name', 'img_url', 'status'].some((key) => current[key] !== doc[key]);
564
+ if (!current || changed) {
560
565
  const person = new this.Contact(doc);
561
566
  const cached_chat = deserialize(await this.engine.get(`/chat/${doc.id}`));
562
- this.emit('contact:created', person, new this.Chat(cached_chat ?? { id: doc.id, name: person.name }), this);
567
+ const chat = new this.Chat(cached_chat ?? { id: doc.id, name: person.name });
568
+ this.emit(current ? 'contact:updated' : 'contact:created', person, chat, this);
563
569
  }
564
570
  }
565
571
  /** @internal */
package/package.json CHANGED
@@ -72,7 +72,7 @@
72
72
  "release": "npm publish --access public"
73
73
  },
74
74
  "types": "./build/esm/index.d.ts",
75
- "version": "6.1.2",
75
+ "version": "6.1.3",
76
76
  "engines": {
77
77
  "node": ">=20"
78
78
  },