Skip to content

Commit

Permalink
feat: Add groups to recipients if flag
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Mar 21, 2024
1 parent 2d08da1 commit 4ac2199
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/cozy-sharing/src/components/ShareByEmail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'
import React, { useState } from 'react'

import { useClient } from 'cozy-client'
import flag from 'cozy-flags'
import Alerter from 'cozy-ui/transpiled/react/deprecated/Alerter'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

Expand All @@ -11,6 +12,7 @@ import ShareSubmit from './Sharesubmit'
import ShareTypeSelect from './Sharetypeselect'
import { getOrCreateFromArray } from '../helpers/contacts'
import {
mergeRecipients,
spreadGroupAndMergeRecipients,
hasReachRecipientsLimit
} from '../helpers/recipients'
Expand Down Expand Up @@ -47,11 +49,9 @@ export const ShareByEmail = ({
}

const onRecipientPick = recipient => {
const mergedRecipients = spreadGroupAndMergeRecipients(
recipients,
recipient,
contacts
)
const mergedRecipients = flag('sharing.show-recipient-groups')
? mergeRecipients(recipients, recipient)
: spreadGroupAndMergeRecipients(recipients, recipient, contacts)
setRecipients(mergedRecipients)
}

Expand Down
4 changes: 4 additions & 0 deletions packages/cozy-sharing/src/helpers/recipients.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ export const spreadGroupAndMergeRecipients = (

return [...recipients, ...filtered]
}

export const mergeRecipients = (recipients, newRecipient) => {
return [...recipients, newRecipient]
}

0 comments on commit 4ac2199

Please sign in to comment.