Use guard clauses if possible

This commit is contained in:
roschaefer 2019-08-26 16:53:22 +02:00
parent 75d984073d
commit 9f6757f409

View File

@ -11,19 +11,19 @@ const filterForBlockedUsers = async (params, context) => {
getBlockedByUsers(context),
])
const badIds = [...blockedByUsers.map(b => b.id), ...blockedUsers.map(b => b.id)]
if (badIds.length) {
params.filter = mergeWith(
params.filter,
{
author_not: { id_in: badIds },
},
(objValue, srcValue) => {
if (isArray(objValue)) {
return objValue.concat(srcValue)
}
},
)
}
if (!badIds.length) return params
params.filter = mergeWith(
params.filter,
{
author_not: { id_in: badIds },
},
(objValue, srcValue) => {
if (isArray(objValue)) {
return objValue.concat(srcValue)
}
},
)
return params
}