How to use the cozy-client.fetchPolicies 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.github.io / en / cozy-banks / src / ducks / balance / AccountRow.jsx View on Github external
{showUpdatedAtOutside && (
          <div>
            
          </div>
        )}
      
    )
  }
}

export default compose(
  queryConnect({
    triggersCol: {
      ...triggersConn,
      fetchPolicy: CozyClient.fetchPolicies.noFetch
    }
  }),
  connect((state, { account }) =&gt; {
    const warningLimits = getWarningLimitPerAccount(state)
    const accountLimit = warningLimits[account._id]
    return {
      hasWarning: accountLimit ? accountLimit &gt; account.balance : false
    }
  }),
  withBreakpoints(),
  translate(),
  React.memo,
  withClient
)(AccountRow)
github cozy / cozy.github.io / en / cozy-banks / src / components / KonnectorUpdateInfo / index.jsx View on Github external
dangerouslySetInnerHTML={{
              __html: t('KonnectorUpdateInfo.content')
            }}
          /&gt;
        }
        icon="warning"
        isImportant
      /&gt;
    
  )
}

const outdatedKonnectors = {
  query: () =&gt;
    Q(KONNECTOR_DOCTYPE).where({ available_version: { $exists: true } }),
  fetchPolicy: CozyClient.fetchPolicies.olderThan(30 * 1000),
  as: 'outdatedKonnectors'
}

export default compose(
  withClient,
  queryConnect({
    outdatedKonnectors
  }),
  withBreakpoints(),
  React.memo
)(KonnectorUpdateInfo)
github cozy / cozy.github.io / en / cozy-banks / src / doctypes.js View on Github external
attributes: {},
    relationships: {}
  },
  stats: {
    doctype: BANK_ACCOUNT_STATS_DOCTYPE,
    attributes: {},
    relationships: {
      account: {
        type: 'has-one',
        doctype: ACCOUNT_DOCTYPE
      }
    }
  }
}

const older30s = CozyClient.fetchPolicies.olderThan(30 * 1000)

export const accountsConn = {
  query: () => Q(ACCOUNT_DOCTYPE).include(['owners']),
  as: 'accounts',
  fetchPolicy: older30s
}

export const groupsConn = {
  query: () => Q(GROUP_DOCTYPE),
  as: 'groups',
  fetchPolicy: older30s
}

export const triggersConn = {
  query: () => Q(TRIGGER_DOCTYPE),
  as: 'triggers'
github cozy / cozy.github.io / en / cozy-banks / src / ducks / recurrence / queries.js View on Github external
import CozyClient, { Q } from 'cozy-client'
import { TRANSACTION_DOCTYPE } from 'doctypes'

const older30s = CozyClient.fetchPolicies.olderThan(30 * 1000)

export const queryRecurrenceTransactions = recurrence =>
  Q(TRANSACTION_DOCTYPE).where({
    'relationships.recurrence.data._id': recurrence._id
  })

export const queryRecurrencesTransactions = recurrences =>
  Q(TRANSACTION_DOCTYPE).where({
    'relationships.recurrence.data._id': {
      $in: recurrences.map(x => x._id)
    }
  })

export const bundleTransactionsQueryConn = ({ bundle }) => {
  return {
    query: () =>
github cozy / cozy.github.io / en / cozy-banks / src / ducks / transactions / TransactionPageErrors / TransactionPageErrors.jsx View on Github external
'errored-trigger': TriggerErrorCard
}

TransactionPageErrors.propTypes = {
  triggerCol: PropTypes.object.isRequired,
  accounts: PropTypes.array.isRequired
}

export default compose(
  connect(state => ({
    accounts: getFilteredAccounts(state)
  })),
  queryConnect({
    triggerCol: {
      ...triggersConn,
      fetchPolicy: CozyClient.fetchPolicies.noFetch
    }
  }),
  React.memo
)(TransactionPageErrors)