Skip to content

Commit

Permalink
Update AnnotationsChannel.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogo-mit committed Nov 16, 2023
1 parent fa32db2 commit 3a3e9fc
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/components/DashboardChannels/AnnotationsChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
: <></>;

Expand Down Expand Up @@ -232,7 +232,28 @@ export default function AnnotationsChannel({
byDateCreated: <CalendarEventFill size={14} style={{ marginRight: 4 }} />,
};

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 = [
{
Expand Down

0 comments on commit 3a3e9fc

Please sign in to comment.