diff --git a/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js b/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js index 38954576b4e6db24ff56c085b747cdca3f919c55..c449426ad91a4c5d541c75a602250c2dad27d2f9 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js +++ b/packages/component-faraday-ui/src/contextualBoxes/AssignHE.js @@ -75,6 +75,7 @@ const AssignHE = ({ <OpenModal confirmText="Invite" isFetching={isFetching} + modalKey={`${he.id}-invitehe`} onConfirm={inviteHandlingEditor(he)} subtitle={he.name} title="Confirm Invitation" diff --git a/packages/xpub-faraday/config/authsome-helpers.js b/packages/xpub-faraday/config/authsome-helpers.js index 2a154bacf92ac6fba8607402e357140f0748fe65..c028d702ddb9099bec210d1a2c46f79bd8ed0509 100644 --- a/packages/xpub-faraday/config/authsome-helpers.js +++ b/packages/xpub-faraday/config/authsome-helpers.js @@ -1,6 +1,6 @@ const { omit, get, last } = require('lodash') - const config = require('config') +const logger = require('@pubsweet/logger') const statuses = config.get('statuses') @@ -206,23 +206,30 @@ const parseUser = ({ user }) => omit(user, sensitiveUserProperties) const getCollections = async ({ user, models }) => { const userPermisssions = await getUserPermissions({ user, Team: models.Team }) - return Promise.all( + return (await Promise.all( userPermisssions.map(async up => { let fragment = {} let collection = {} - if (up.objectType === 'collection') { - collection = await models.Collection.find(up.objectId) - const latestFragmentId = - collection.fragments[collection.fragments.length - 1] - collection.currentVersion = await models.Fragment.find(latestFragmentId) - } else { - fragment = await models.Fragment.find(up.objectId) - collection = await models.Collection.find(fragment.collectionId) - collection.currentVersion = stripeFragmentByRole({ - fragment, - role: up.role, - user, - }) + try { + if (up.objectType === 'collection') { + collection = await models.Collection.find(up.objectId) + const latestFragmentId = + collection.fragments[collection.fragments.length - 1] + collection.currentVersion = await models.Fragment.find( + latestFragmentId, + ) + } else { + fragment = await models.Fragment.find(up.objectId) + collection = await models.Collection.find(fragment.collectionId) + collection.currentVersion = stripeFragmentByRole({ + fragment, + role: up.role, + user, + }) + } + } catch (e) { + logger.error(`DB ERROR: ${e.message}`) + return null } const status = get(collection, 'status', 'draft') collection.visibleStatus = get(statuses, `${status}.${up.role}.label`) @@ -234,7 +241,7 @@ const getCollections = async ({ user, models }) => { return stripedColl.coll }), - ) + )).filter(Boolean) } module.exports = {