From 7c2d02e6054924531a4f3a634482abadeecb2d21 Mon Sep 17 00:00:00 2001 From: Joshua Mbogo <55801923+mbogo-mit@users.noreply.github.com> Date: Fri, 17 Nov 2023 10:28:56 -0500 Subject: [PATCH] updates to filtering --- .../DashboardChannels/AnnotationsChannel.js | 47 ++++++++++--------- .../DashboardChannels/GroupsChannel.js | 2 +- src/components/FilterPopover/FilterPopover.js | 4 +- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/components/DashboardChannels/AnnotationsChannel.js b/src/components/DashboardChannels/AnnotationsChannel.js index 52a51478..2d79055b 100644 --- a/src/components/DashboardChannels/AnnotationsChannel.js +++ b/src/components/DashboardChannels/AnnotationsChannel.js @@ -171,6 +171,29 @@ export default function AnnotationsChannel({ callback(); }).current; + const getDocumentFromDocuments = () => { + if (selectedGroupId && selectedDocumentId) { + const obj = documents[selectedGroupId] + + 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 loadComponent = loadMore ? : ( @@ -231,29 +254,7 @@ export default function AnnotationsChannel({ byTag: , byDateCreated: , }; - - 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 = [ { diff --git a/src/components/DashboardChannels/GroupsChannel.js b/src/components/DashboardChannels/GroupsChannel.js index 5082a838..486e080c 100644 --- a/src/components/DashboardChannels/GroupsChannel.js +++ b/src/components/DashboardChannels/GroupsChannel.js @@ -115,7 +115,7 @@ export default function GroupsChannel({ ) || []).concat(seachQueryGroups.sort(sortGroups)); // Personal Psuedo group will only be apart of the active groups not archived - console.log(rawGroupTiles); + // console.log(rawGroupTiles); groupTiles = rawGroupTiles.map(({ id, name, memberCount, role, isPrivateGroup, }) => ( diff --git a/src/components/FilterPopover/FilterPopover.js b/src/components/FilterPopover/FilterPopover.js index dfd79e8a..251f8e30 100644 --- a/src/components/FilterPopover/FilterPopover.js +++ b/src/components/FilterPopover/FilterPopover.js @@ -134,7 +134,7 @@ function FilterPopover({ session }) { }; const GenerateFilterOptions = (userEmail, annotations, filters) => { - console.log('annotations: ', annotations) + // console.log('annotations: ', annotations) // this function takes in a list of annotations and returns an object of all // the filter options that are available for this list of annotations and how // many matches each option has with the current filtres applied @@ -222,7 +222,7 @@ function FilterPopover({ session }) { const filterOptions = GenerateFilterOptions(session.user.email, channelAnnotations, f); - console.log('filterOptions: ', filterOptions) + // console.log('filterOptions: ', filterOptions) const numberOfMatchesForNoTag = GetNumberOfMatchesForNoTag(channelAnnotations, f);