How to use the cozy-client.fetchPolicies.olderThan function in cozy-client

To help you get started, we’ve selected a few cozy-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cozy / cozy-ui / react / ContactsListModal / index.jsx View on Github external
import Modal, { ModalHeader, ModalDescription } from '../Modal'
import Spinner from '../Spinner'
import styles from './styles.styl'
import Input from '../Input'
import PropTypes from 'prop-types'
import withBreakpoints from '../helpers/withBreakpoints'
import Button from '../Button'
import { Contact } from 'cozy-doctypes'
import AddContactButton from './AddContactButton'
import EmptyMessage from './EmptyMessage'

const thirtySeconds = 30000
// the check in the next line is because it otherwise requires cozy-client
// even for libs or apps that do not use cozy-client nor ContactsListModal
const olderThan30s = fetchPolicies
  ? fetchPolicies.olderThan(thirtySeconds)
  : () => true

const mkFilter = filterStr => contacts => {
  if (!filterStr) {
    return contacts
  }

  const f = filterStr.toLowerCase()

  // TODO better filtering methods can be extracted from drive. See https://github.com/cozy/cozy-ui/pull/1273#discussion_r351845385
  return contacts.filter(contact => {
    const displayName = Contact.getDisplayName(contact)

    if (!displayName) {
      return false
    }