// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import { take } from 'lodash'; import { Intl } from './Intl'; import type { LocalizerType } from '../types/Util'; import { UserText } from './UserText'; type PropsType = { i18n: LocalizerType; nameClassName?: string; sharedGroupNames: ReadonlyArray; }; export function SharedGroupNames({ i18n, nameClassName, sharedGroupNames, }: PropsType): JSX.Element { const firstThreeGroups = take(sharedGroupNames, 3).map((group, i) => ( // We cannot guarantee uniqueness of group names // eslint-disable-next-line react/no-array-index-key )); if (sharedGroupNames.length >= 5) { const remainingCount = sharedGroupNames.length - 3; return ( ); } if (sharedGroupNames.length === 4) { return ( ); } if (firstThreeGroups.length === 3) { return ( ); } if (firstThreeGroups.length >= 2) { return ( ); } if (firstThreeGroups.length >= 1) { return ( ); } return <>{i18n('icu:no-groups-in-common')}; }