diff --git a/src/components/DashboardChannels/AnnotationsChannel.js b/src/components/DashboardChannels/AnnotationsChannel.js index 2cd181b1..52a51478 100644 --- a/src/components/DashboardChannels/AnnotationsChannel.js +++ b/src/components/DashboardChannels/AnnotationsChannel.js @@ -189,9 +189,9 @@ export default function AnnotationsChannel({ ); const ASLoadMoreAnnos = ( - annotations[slug]?.countByPermissions + (annotations[slug] && annotations[slug]?.countByPermissions && annotations[slug]?.countByPermissions[selectedPermissions] - > annotations[slug][selectedPermissions].length) + > (annotations[slug][selectedPermissions] || []).filter(byWithGroupId).length)) ? loadComponent : <>; @@ -232,7 +232,28 @@ export default function AnnotationsChannel({ byDateCreated: , }; - const byWithGroupId = (anno) => byGroupFilterMatch(anno?.creator?.withGroupId ? [anno?.creator?.withGroupId] : [], [selectedGroupId]); + const getDocumentFromDocuments = () => { + if (selectedGroupId && selectedDocumentId) { + const obj = documents[selectedGroupId] + // console.log('obj: ', Object.entries(obj)) + for (const [key, arr] of Object.entries(obj)) { + if (Array.isArray(arr)) { + for (let d of arr) { + if (d._id === selectedDocumentId) { + return d + } + } + } + + } + } + + return undefined + } + + const byWithGroupId = (anno) => ( + getDocumentFromDocuments()?.version === 4 ? byGroupFilterMatch(anno?.creator?.withGroupId ? [anno?.creator?.withGroupId] : [], [selectedGroupId]) : true + ); const buttons = [ {