Skip to content

Commit

Permalink
Merge pull request #345 from mitaai/preview
Browse files Browse the repository at this point in the history
Preview
  • Loading branch information
mbogo-mit authored Nov 22, 2023
2 parents f09ef86 + 6656227 commit fabc1b8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/components/AnnotationChannel/AnnotationChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ const AnnotationChannelWithContext = ({
setLargeFontSize,
}) => {

console.log('membersIntersection: ', membersIntersection)
const [, documentZoom] = useContext(DocumentContext);
const [channelAnnotations, , expandedAnnotations] = useContext(DocumentAnnotationsContext);
const [documentFilters] = useContext(DocumentFiltersContext);
Expand Down
13 changes: 7 additions & 6 deletions src/components/DashboardChannels/AnnotationsChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,16 @@ export default function AnnotationsChannel({
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
if (obj) {
for (const [key, arr] of Object.entries(obj)) {
if (Array.isArray(arr)) {
for (let d of arr) {
if (d._id === selectedDocumentId) {
return d
}
}
}
}

}
}

Expand Down
15 changes: 6 additions & 9 deletions src/components/FilterPopover/FilterPopover.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function FilterPopover({ session }) {
documentGroupNameMapping,
defaultGroupFilteringId,
defaultGroupFilteringIdSelected,
documentVersion,
] = useContext(DocumentFiltersContext);

const [byTagsTypeheadMarginTop, setByTagsTypeheadMarginTop] = useState(0);
Expand Down Expand Up @@ -241,15 +242,12 @@ function FilterPopover({ session }) {
});

useEffect(() => {
console.log('defaultGroupFilteringIdSelected: ', defaultGroupFilteringIdSelected)
if (documentVersion < 4 || !documentVersion) return;
// console.log('defaultGroupFilteringIdSelected: ', defaultGroupFilteringIdSelected)
if (!defaultGroupFilteringIdSelected) return;

console.log('defaultGroupFilteringId: ', defaultGroupFilteringId)

console.log('filterOptions.byGroup: ', filterOptions.byGroup)

const selected = filterOptions.byGroup.find(({ id }) => id === defaultGroupFilteringId)
console.log('selected: ', selected)

if (selected) {
updateFilters('byGroup', [selected])
}
Expand Down Expand Up @@ -277,7 +275,6 @@ function FilterPopover({ session }) {
}, [documentFilters]);

const updateFilters = (type, selected) => {
console.log('selected: ', selected)
documentFilters.filters[type] = selected;

const annotationIds = FilterAnnotations(channelAnnotations, {
Expand Down Expand Up @@ -400,8 +397,8 @@ function FilterPopover({ session }) {
placeholder="Select one or more groups to filter by"
/>
<Form.Text className="text-muted">
{defaultGroupFilteringIdSelected
? '' : 'This option is only enabled for v4 and higher documnents (updated 10/06/2023)'
{documentVersion >= 4
? '' : 'Update! This filter option only works fully for documents made after October 6th, 2023'
}
</Form.Text>

Expand Down
4 changes: 1 addition & 3 deletions src/pages/documents/[slug]/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ const DocumentPage = ({
}
}

console.log('document: ', document)

const documentIsPDF = document && document.uploadContentType && document.uploadContentType.includes('pdf');

const focusedAnnotationsRef = useRef({ left: null, right: null }).current;
Expand Down Expand Up @@ -940,7 +938,7 @@ const DocumentPage = ({
]}
>
<DocumentFiltersContext.Provider
value={[documentFilters, setDocumentFilters, FilterAnnotations, groupNameMapping, defaultGroupFilteringId, defaultGroupFilteringIdSelected]}
value={[documentFilters, setDocumentFilters, FilterAnnotations, groupNameMapping, defaultGroupFilteringId, defaultGroupFilteringIdSelected, document?.version]}
>
<Layout
type="document"
Expand Down

0 comments on commit fabc1b8

Please sign in to comment.