cozy-client 46.7.0 → 46.7.1

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.
@@ -2705,7 +2705,7 @@ var CozyClient = /*#__PURE__*/function () {
2705
2705
  CozyClient.hooks = CozyClient.hooks || {};
2706
2706
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2707
2707
 
2708
- CozyClient.version = "46.7.0";
2708
+ CozyClient.version = "46.7.1";
2709
2709
 
2710
2710
  _microee.default.mixin(CozyClient);
2711
2711
 
@@ -30,7 +30,7 @@ var getPrimaryOrFirst = function getPrimaryOrFirst(property) {
30
30
  /**
31
31
  * Returns the initials of the contact.
32
32
  *
33
- * @param {object} contact - A contact
33
+ * @param {import('../types').IOCozyContact} contact - A contact
34
34
  * @returns {string} - the contact's initials
35
35
  */
36
36
 
@@ -38,7 +38,9 @@ var getPrimaryOrFirst = function getPrimaryOrFirst(property) {
38
38
  exports.getPrimaryOrFirst = getPrimaryOrFirst;
39
39
 
40
40
  var getInitials = function getInitials(contact) {
41
- if (contact.name && !(0, _isEmpty.default)(contact.name)) {
41
+ var _contact$name, _contact$name2;
42
+
43
+ if (contact !== null && contact !== void 0 && (_contact$name = contact.name) !== null && _contact$name !== void 0 && _contact$name.givenName || contact !== null && contact !== void 0 && (_contact$name2 = contact.name) !== null && _contact$name2 !== void 0 && _contact$name2.familyName) {
42
44
  return ['givenName', 'familyName'].map(function (part) {
43
45
  return (0, _get.default)(contact, ['name', part, 0], '');
44
46
  }).join('').toUpperCase();
@@ -98,6 +98,23 @@ describe('getInitials', () => {
98
98
  expect(result).toEqual('A')
99
99
  })
100
100
 
101
+ it('should return the first letter of the primary email if contact has empty familyName and givenName', () => {
102
+ const contact = {
103
+ name: {
104
+ familyName: '',
105
+ givenName: ''
106
+ },
107
+ email: [
108
+ {
109
+ address: 'arya.stark@thenorth.westeros',
110
+ primary: true
111
+ }
112
+ ]
113
+ }
114
+ const result = getInitials(contact)
115
+ expect(result).toEqual('A')
116
+ })
117
+
101
118
  it('should return the first letter of the cozy domain if contact has empty name, an empty email but has a cozy url', () => {
102
119
  const contact = {
103
120
  name: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "46.7.0",
3
+ "version": "46.7.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -75,5 +75,5 @@
75
75
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
76
76
  },
77
77
  "sideEffects": false,
78
- "gitHead": "a6647a5f2d00b2ea9907e5b895e72e5de5360b93"
78
+ "gitHead": "462bc3a07416daf84b5b14beac5e1f06000d162a"
79
79
  }
@@ -1,6 +1,6 @@
1
1
  export const CONTACTS_DOCTYPE: "io.cozy.contacts";
2
2
  export function getPrimaryOrFirst(property: any): (obj: any) => any;
3
- export function getInitials(contact: object): string;
3
+ export function getInitials(contact: import('../types').IOCozyContact): string;
4
4
  export function getPrimaryEmail(contact: object): string;
5
5
  export function getPrimaryCozy(contact: object): string;
6
6
  export function getPrimaryCozyDomain(contact: object): string;