cozy-sharing 12.1.0 → 12.2.0

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [12.2.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@12.1.0...cozy-sharing@12.2.0) (2024-03-22)
7
+
8
+
9
+ ### Features
10
+
11
+ * Allow to add group with only more than one member ([177dc4a](https://github.com/cozy/cozy-libs/commit/177dc4a4fbceefed1ce52f2a5275c67e46b6430f))
12
+
13
+
14
+
15
+
16
+
6
17
  # [12.1.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@12.0.0...cozy-sharing@12.1.0) (2024-03-22)
7
18
 
8
19
 
@@ -1,4 +1,3 @@
1
- import get from 'lodash/get';
2
1
  import PropTypes from 'prop-types';
3
2
  import React from 'react';
4
3
  import { models } from 'cozy-client';
@@ -10,8 +9,7 @@ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
10
9
  import { Contact, Group, getDisplayName, getInitials } from '../models';
11
10
  var ContactModel = models.contact;
12
11
  export var ContactSuggestion = function ContactSuggestion(_ref) {
13
- var contactOrGroup = _ref.contactOrGroup,
14
- contacts = _ref.contacts;
12
+ var contactOrGroup = _ref.contactOrGroup;
15
13
 
16
14
  var _useI18n = useI18n(),
17
15
  t = _useI18n.t;
@@ -20,19 +18,10 @@ export var ContactSuggestion = function ContactSuggestion(_ref) {
20
18
 
21
19
  if (contactOrGroup._type === Group.doctype) {
22
20
  name = contactOrGroup.name;
23
- var membersCount = contacts.reduce(function (total, contact) {
24
- if (get(contact, 'relationships.groups.data', []).map(function (group) {
25
- return group._id;
26
- }).includes(contactOrGroup._id)) {
27
- return total + 1;
28
- }
29
-
30
- return total;
31
- }, 0).toString();
21
+ avatarText = 'G';
32
22
  details = t('Share.members.count', {
33
- smart_count: membersCount
23
+ smart_count: contactOrGroup.membersCount.toString()
34
24
  });
35
- avatarText = 'G';
36
25
  } else {
37
26
  name = getDisplayName(contactOrGroup);
38
27
  avatarText = getInitials(contactOrGroup);
@@ -1,21 +1,17 @@
1
- import { mount } from 'enzyme';
1
+ import { render, screen } from '@testing-library/react';
2
2
  import React from 'react';
3
3
  import { ContactSuggestion } from './ContactSuggestion';
4
4
  import AppLike from '../../test/AppLike';
5
-
6
- var WrappingComponent = function WrappingComponent(_ref) {
7
- var children = _ref.children;
8
- return /*#__PURE__*/React.createElement(AppLike, null, children);
9
- };
10
-
11
5
  describe('ContactSuggestion component', function () {
12
- var fakeT = jest.fn(function (s, args) {
13
- if (s === 'Share.members.count') {
14
- return "".concat(args.smart_count, " members");
15
- }
6
+ var setup = function setup(_ref) {
7
+ var contactOrGroup = _ref.contactOrGroup;
8
+ return render( /*#__PURE__*/React.createElement(ContactSuggestion, {
9
+ contactOrGroup: contactOrGroup
10
+ }), {
11
+ wrapper: AppLike
12
+ });
13
+ };
16
14
 
17
- return s;
18
- });
19
15
  it('should display contact suggestion for a contact', function () {
20
16
  var jonSnow = {
21
17
  _id: 'f3a4e501-abbd',
@@ -34,17 +30,11 @@ describe('ContactSuggestion component', function () {
34
30
  }],
35
31
  _type: 'io.cozy.contacts'
36
32
  };
37
- var contacts = [jonSnow];
38
- var props = {
39
- contactOrGroup: jonSnow,
40
- contacts: contacts,
41
- t: fakeT
42
- };
43
- var jsx = /*#__PURE__*/React.createElement(ContactSuggestion, props);
44
- var wrapper = mount(jsx, {
45
- wrappingComponent: WrappingComponent
33
+ setup({
34
+ contactOrGroup: jonSnow
46
35
  });
47
- expect(wrapper).toMatchSnapshot();
36
+ expect(screen.getByText('Jon Snow')).toBeInTheDocument();
37
+ expect(screen.getByText('https://jonsnow.mycozy.cloud')).toBeInTheDocument();
48
38
  });
49
39
  it('should display contact suggestion for a contact without fullname (for example created by a share modal)', function () {
50
40
  var jonSnow = {
@@ -57,94 +47,22 @@ describe('ContactSuggestion component', function () {
57
47
  name: undefined,
58
48
  _type: 'io.cozy.contacts'
59
49
  };
60
- var contacts = [jonSnow];
61
- var props = {
62
- contactOrGroup: jonSnow,
63
- contacts: contacts,
64
- t: fakeT
65
- };
66
- var jsx = /*#__PURE__*/React.createElement(ContactSuggestion, props);
67
- var wrapper = mount(jsx, {
68
- wrappingComponent: WrappingComponent
50
+ setup({
51
+ contactOrGroup: jonSnow
69
52
  });
70
- expect(wrapper).toMatchSnapshot();
53
+ expect(screen.getByText('jon.snow@email.com')).toBeInTheDocument();
71
54
  });
72
55
  it('should display contact suggestion for a group', function () {
73
- var jon = {
74
- _id: 'f3a4e501-abbd',
75
- fullname: 'Jon Snow',
76
- name: {
77
- givenName: 'Jon',
78
- familyName: 'Snow'
79
- },
80
- email: [{
81
- address: 'jon.snow@email.com',
82
- type: 'primary'
83
- }],
84
- _type: 'io.cozy.contacts',
85
- relationships: {
86
- groups: {
87
- data: [{
88
- _id: '610718e6-2d7a',
89
- _type: 'io.cozy.contacts.groups'
90
- }]
91
- }
92
- }
93
- };
94
- var cersei = {
95
- _id: '42dc490a-7878',
96
- fullname: 'Cersei Lannister',
97
- name: {
98
- givenName: 'Cersei',
99
- familyName: 'Lannister'
100
- },
101
- email: [{
102
- address: 'cersei@email.com',
103
- type: 'primary'
104
- }],
105
- _type: 'io.cozy.contacts',
106
- relationships: {
107
- groups: {
108
- data: []
109
- }
110
- }
111
- };
112
- var sam = {
113
- _id: 'b5bed853-93da',
114
- fullname: 'Samwell Tarly',
115
- name: {
116
- givenName: 'Samwell',
117
- familyName: 'Tarly'
118
- },
119
- email: [{
120
- address: 'samwell@email.com',
121
- type: 'primary'
122
- }],
123
- _type: 'io.cozy.contacts',
124
- relationships: {
125
- groups: {
126
- data: [{
127
- _id: '610718e6-2d7a',
128
- _type: 'io.cozy.contacts.groups'
129
- }]
130
- }
131
- }
132
- };
133
- var contacts = [jon, cersei, sam];
134
56
  var theNightsWatch = {
135
57
  _id: '610718e6-2d7a',
136
58
  name: "The Night's Watch",
137
- _type: 'io.cozy.contacts.groups'
138
- };
139
- var props = {
140
- contactOrGroup: theNightsWatch,
141
- contacts: contacts,
142
- t: fakeT
59
+ _type: 'io.cozy.contacts.groups',
60
+ membersCount: 2
143
61
  };
144
- var jsx = /*#__PURE__*/React.createElement(ContactSuggestion, props);
145
- var wrapper = mount(jsx, {
146
- wrappingComponent: WrappingComponent
62
+ setup({
63
+ contactOrGroup: theNightsWatch
147
64
  });
148
- expect(wrapper).toMatchSnapshot();
65
+ expect(screen.getByText("The Night's Watch")).toBeInTheDocument();
66
+ expect(screen.getByText('2 members')).toBeInTheDocument();
149
67
  });
150
68
  });
@@ -174,9 +174,6 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
174
174
 
175
175
  var renderSuggestion = function renderSuggestion(contactOrGroup) {
176
176
  return /*#__PURE__*/React.createElement(ContactSuggestion, {
177
- contacts: contactsAndGroups.filter(function (item) {
178
- return item._type === Contact.doctype;
179
- }),
180
177
  contactOrGroup: contactOrGroup
181
178
  });
182
179
  };
@@ -1,5 +1,12 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
+
9
+ import get from 'lodash/get';
3
10
  import PropTypes from 'prop-types';
4
11
  import React, { useState, useEffect } from 'react';
5
12
  import ShareAutosuggest from './ShareAutosuggest';
@@ -35,7 +42,22 @@ var ShareRecipientsInput = function ShareRecipientsInput(_ref) {
35
42
  if (contacts.hasMore || contacts.fetchStatus === 'loading') {
36
43
  return contacts.data;
37
44
  } else {
38
- return [].concat(_toConsumableArray(contacts.data), _toConsumableArray(contactGroups.data));
45
+ var contactGroupsWithCount = contactGroups.data.map(function (contactGroup) {
46
+ return _objectSpread(_objectSpread({}, contactGroup), {}, {
47
+ membersCount: contacts.data.reduce(function (total, contact) {
48
+ if (get(contact, 'relationships.groups.data', []).map(function (group) {
49
+ return group._id;
50
+ }).includes(contactGroup._id)) {
51
+ return total + 1;
52
+ }
53
+
54
+ return total;
55
+ }, 0)
56
+ });
57
+ }).filter(function (contactGroup) {
58
+ return contactGroup.membersCount > 0;
59
+ });
60
+ return [].concat(_toConsumableArray(contacts.data), _toConsumableArray(contactGroupsWithCount));
39
61
  }
40
62
  };
41
63
 
@@ -1,119 +1,210 @@
1
- import { shallow } from 'enzyme';
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { render, screen } from '@testing-library/react';
2
4
  import React from 'react';
3
5
  import ShareRecipientsInput from './ShareRecipientsInput';
4
- describe('ShareRecipientsInput component', function () {
5
- it('should match snapshot', function () {
6
- var props = {
7
- client: '',
8
- label: 'Recipients',
9
- contacts: {
10
- id: 'contacts',
11
- fetchStatus: 'loaded',
12
- hasMore: false,
13
- data: [{
14
- id: 'df563cc4-6440',
15
- _id: 'df563cc4-6440',
16
- _type: 'io.cozy.contacts',
17
- name: {
18
- givenName: 'Michale',
19
- familyName: 'Russel'
20
- }
21
- }, {
22
- id: '5a3b4ccf-c257',
23
- _id: '5a3b4ccf-c257',
24
- _type: 'io.cozy.contacts',
25
- name: {
26
- givenName: 'Teagan',
27
- familyName: 'Wolf'
28
- }
29
- }]
30
- },
31
- contactGroups: {
32
- id: 'groups',
33
- fetchStatus: 'loaded',
34
- hasMore: false,
35
- data: [{
36
- id: 'fe86af20-c6c5',
37
- name: "The Night's Watch",
38
- _id: 'fe86af20-c6c5',
39
- _type: 'io.cozy.contacts.groups'
40
- }, {
41
- id: '3d8193ab-2ce4',
42
- name: 'The North',
43
- _id: '3d8193ab-2ce4',
44
- _type: 'io.cozy.contacts.groups'
45
- }]
46
- },
47
- recipients: [{
48
- id: '5a3b4ccf-c257',
49
- name: {
50
- givenName: 'Teagan',
51
- familyName: 'Wolf'
52
- }
53
- }],
54
- onPick: jest.fn().mockName('onPick'),
55
- onRemove: jest.fn().mockName('onRemove'),
56
- placeholder: 'Enter recipients here'
57
- };
58
- var jsx = /*#__PURE__*/React.createElement(ShareRecipientsInput, props);
59
- var wrapper = shallow(jsx);
60
- expect(wrapper).toMatchSnapshot();
61
- });
62
- it('should include groups only if all contacts are loaded', function () {
63
- var props = {
64
- client: '',
65
- label: 'Recipients',
66
- contacts: {
67
- id: 'contacts',
68
- fetchStatus: 'loading',
69
- hasMore: false,
70
- data: [{
71
- id: 'df563cc4-6440',
72
- _id: 'df563cc4-6440',
73
- _type: 'io.cozy.contacts',
74
- name: {
75
- givenName: 'Michale',
76
- familyName: 'Russel'
77
- }
78
- }, {
79
- id: '5a3b4ccf-c257',
80
- _id: '5a3b4ccf-c257',
81
- _type: 'io.cozy.contacts',
82
- name: {
83
- givenName: 'Teagan',
84
- familyName: 'Wolf'
85
- }
86
- }]
87
- },
88
- contactGroups: {
89
- id: 'groups',
90
- fetchStatus: 'loaded',
91
- hasMore: false,
92
- data: [{
93
- id: 'fe86af20-c6c5',
94
- name: "The Night's Watch",
95
- _id: 'fe86af20-c6c5',
96
- _type: 'io.cozy.contacts.groups'
97
- }, {
98
- id: '3d8193ab-2ce4',
99
- name: 'The North',
100
- _id: '3d8193ab-2ce4',
101
- _type: 'io.cozy.contacts.groups'
102
- }]
103
- },
104
- recipients: [{
105
- id: '5a3b4ccf-c257',
106
- name: {
107
- givenName: 'Teagan',
108
- familyName: 'Wolf'
6
+ jest.mock('./ShareAutosuggest', function () {
7
+ return {
8
+ __esModule: true,
9
+ default: function _default(_ref) {
10
+ var contactsAndGroups = _ref.contactsAndGroups;
11
+ return /*#__PURE__*/React.createElement("ul", null, contactsAndGroups.map(function (contactOrGroup) {
12
+ if (contactOrGroup._type === 'io.cozy.contacts') {
13
+ return /*#__PURE__*/React.createElement("li", {
14
+ key: contactOrGroup.id
15
+ }, contactOrGroup.name.givenName, " ", contactOrGroup.name.familyName);
16
+ } else {
17
+ return /*#__PURE__*/React.createElement("li", {
18
+ key: contactOrGroup.id
19
+ }, contactOrGroup.name);
109
20
  }
110
- }],
111
- onPick: jest.fn().mockName('onPick'),
112
- onRemove: jest.fn().mockName('onRemove'),
113
- placeholder: 'Enter recipients here'
114
- };
115
- var jsx = /*#__PURE__*/React.createElement(ShareRecipientsInput, props);
116
- var wrapper = shallow(jsx);
117
- expect(wrapper).toMatchSnapshot();
118
- });
21
+ }));
22
+ }
23
+ };
24
+ });
25
+ describe('ShareRecipientsInput component', function () {
26
+ var setup = function setup(_ref2) {
27
+ var contacts = _ref2.contacts,
28
+ contactGroups = _ref2.contactGroups;
29
+ render( /*#__PURE__*/React.createElement(ShareRecipientsInput, {
30
+ contacts: contacts,
31
+ contactGroups: contactGroups,
32
+ onPick: function onPick() {},
33
+ onRemove: function onRemove() {},
34
+ placeholder: "Enter recipients here"
35
+ }));
36
+ };
37
+
38
+ it('should include groups and contacts when are loaded', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
39
+ var contacts, contactGroups;
40
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
41
+ while (1) switch (_context.prev = _context.next) {
42
+ case 0:
43
+ contacts = {
44
+ id: 'contacts',
45
+ fetchStatus: 'loaded',
46
+ hasMore: false,
47
+ data: [{
48
+ id: 'df563cc4-6440',
49
+ _id: 'df563cc4-6440',
50
+ _type: 'io.cozy.contacts',
51
+ name: {
52
+ givenName: 'Michale',
53
+ familyName: 'Russel'
54
+ }
55
+ }, {
56
+ id: '5a3b4ccf-c257',
57
+ _id: '5a3b4ccf-c257',
58
+ _type: 'io.cozy.contacts',
59
+ name: {
60
+ givenName: 'Teagan',
61
+ familyName: 'Wolf'
62
+ },
63
+ relationships: {
64
+ groups: {
65
+ data: [{
66
+ _id: 'fe86af20-c6c5',
67
+ _type: 'io.cozy.contacts.groups'
68
+ }]
69
+ }
70
+ }
71
+ }]
72
+ };
73
+ contactGroups = {
74
+ id: 'groups',
75
+ fetchStatus: 'loaded',
76
+ hasMore: false,
77
+ data: [{
78
+ id: 'fe86af20-c6c5',
79
+ name: "The Night's Watch",
80
+ _id: 'fe86af20-c6c5',
81
+ _type: 'io.cozy.contacts.groups'
82
+ }]
83
+ };
84
+ setup({
85
+ contacts: contacts,
86
+ contactGroups: contactGroups
87
+ });
88
+ expect(screen.getByText('Michale Russel')).toBeInTheDocument();
89
+ expect(screen.getByText('Teagan Wolf')).toBeInTheDocument();
90
+ expect(screen.getByText("The Night's Watch")).toBeInTheDocument();
91
+
92
+ case 6:
93
+ case "end":
94
+ return _context.stop();
95
+ }
96
+ }, _callee);
97
+ })));
98
+ it('should include groups only if all contacts are loaded', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
99
+ var contacts, contactGroups;
100
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
101
+ while (1) switch (_context2.prev = _context2.next) {
102
+ case 0:
103
+ contacts = {
104
+ id: 'contacts',
105
+ fetchStatus: 'loading',
106
+ hasMore: false,
107
+ data: [{
108
+ id: 'df563cc4-6440',
109
+ _id: 'df563cc4-6440',
110
+ _type: 'io.cozy.contacts',
111
+ name: {
112
+ givenName: 'Michale',
113
+ familyName: 'Russel'
114
+ }
115
+ }, {
116
+ id: '5a3b4ccf-c257',
117
+ _id: '5a3b4ccf-c257',
118
+ _type: 'io.cozy.contacts',
119
+ name: {
120
+ givenName: 'Teagan',
121
+ familyName: 'Wolf'
122
+ },
123
+ relationships: {
124
+ groups: {
125
+ data: [{
126
+ _id: 'fe86af20-c6c5',
127
+ _type: 'io.cozy.contacts.groups'
128
+ }]
129
+ }
130
+ }
131
+ }]
132
+ };
133
+ contactGroups = {
134
+ id: 'groups',
135
+ fetchStatus: 'loaded',
136
+ hasMore: false,
137
+ data: [{
138
+ id: 'fe86af20-c6c5',
139
+ name: "The Night's Watch",
140
+ _id: 'fe86af20-c6c5',
141
+ _type: 'io.cozy.contacts.groups'
142
+ }]
143
+ };
144
+ setup({
145
+ contacts: contacts,
146
+ contactGroups: contactGroups
147
+ });
148
+ expect(screen.getByText('Michale Russel')).toBeInTheDocument();
149
+ expect(screen.getByText('Teagan Wolf')).toBeInTheDocument();
150
+ expect(screen.queryByText("The Night's Watch")).toBeNull();
151
+
152
+ case 6:
153
+ case "end":
154
+ return _context2.stop();
155
+ }
156
+ }, _callee2);
157
+ })));
158
+ it('should include groups only if they have more than one member', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
159
+ var contacts, contactGroups;
160
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
161
+ while (1) switch (_context3.prev = _context3.next) {
162
+ case 0:
163
+ contacts = {
164
+ id: 'contacts',
165
+ fetchStatus: 'loaded',
166
+ hasMore: false,
167
+ data: [{
168
+ id: 'df563cc4-6440',
169
+ _id: 'df563cc4-6440',
170
+ _type: 'io.cozy.contacts',
171
+ name: {
172
+ givenName: 'Michale',
173
+ familyName: 'Russel'
174
+ }
175
+ }, {
176
+ id: '5a3b4ccf-c257',
177
+ _id: '5a3b4ccf-c257',
178
+ _type: 'io.cozy.contacts',
179
+ name: {
180
+ givenName: 'Teagan',
181
+ familyName: 'Wolf'
182
+ }
183
+ }]
184
+ };
185
+ contactGroups = {
186
+ id: 'groups',
187
+ fetchStatus: 'loaded',
188
+ hasMore: false,
189
+ data: [{
190
+ id: 'fe86af20-c6c5',
191
+ name: "The Night's Watch",
192
+ _id: 'fe86af20-c6c5',
193
+ _type: 'io.cozy.contacts.groups'
194
+ }]
195
+ };
196
+ setup({
197
+ contacts: contacts,
198
+ contactGroups: contactGroups
199
+ });
200
+ expect(screen.getByText('Michale Russel')).toBeInTheDocument();
201
+ expect(screen.getByText('Teagan Wolf')).toBeInTheDocument();
202
+ expect(screen.queryByText("The Night's Watch")).toBeNull();
203
+
204
+ case 6:
205
+ case "end":
206
+ return _context3.stop();
207
+ }
208
+ }, _callee3);
209
+ })));
119
210
  });
package/jest.config.js CHANGED
@@ -2,7 +2,8 @@ module.exports = {
2
2
  collectCoverageFrom: [
3
3
  'src/**/*.{js,jsx}',
4
4
  '!**/node_modules/**',
5
- '!**/vendor/**'
5
+ '!**/vendor/**',
6
+ '!**/*.stories.{js,jsx,ts,tsx}'
6
7
  ],
7
8
  snapshotSerializers: ['enzyme-to-json/serializer'],
8
9
  testPathIgnorePatterns: ['node_modules', 'dist', '__tests__'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "12.1.0",
3
+ "version": "12.2.0",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -71,5 +71,5 @@
71
71
  "sideEffects": [
72
72
  "*.css"
73
73
  ],
74
- "gitHead": "5de831d050135822b1b9295ae8888d11f6372ee5"
74
+ "gitHead": "e48ad9475627e2be13c46e6b7be8a9f82215a392"
75
75
  }
@@ -1,4 +1,3 @@
1
- import get from 'lodash/get'
2
1
  import PropTypes from 'prop-types'
3
2
  import React from 'react'
4
3
 
@@ -13,28 +12,15 @@ import { Contact, Group, getDisplayName, getInitials } from '../models'
13
12
 
14
13
  const ContactModel = models.contact
15
14
 
16
- export const ContactSuggestion = ({ contactOrGroup, contacts }) => {
15
+ export const ContactSuggestion = ({ contactOrGroup }) => {
17
16
  const { t } = useI18n()
18
17
  let avatarText, name, details
19
18
  if (contactOrGroup._type === Group.doctype) {
20
19
  name = contactOrGroup.name
21
- const membersCount = contacts
22
- .reduce((total, contact) => {
23
- if (
24
- get(contact, 'relationships.groups.data', [])
25
- .map(group => group._id)
26
- .includes(contactOrGroup._id)
27
- ) {
28
- return total + 1
29
- }
30
-
31
- return total
32
- }, 0)
33
- .toString()
20
+ avatarText = 'G'
34
21
  details = t('Share.members.count', {
35
- smart_count: membersCount
22
+ smart_count: contactOrGroup.membersCount.toString()
36
23
  })
37
- avatarText = 'G'
38
24
  } else {
39
25
  name = getDisplayName(contactOrGroup)
40
26
  avatarText = getInitials(contactOrGroup)