Skip to content

Commit

Permalink
[FIX] have a project specific chip (#671)
Browse files Browse the repository at this point in the history
* have a project specific chip

* edit other references of the chip
  • Loading branch information
jdkent authored Jan 19, 2024
1 parent 3ea0942 commit e1203ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const EditStudyToolbar: React.FC = (props) => {
if (!studyset?.studies) return undefined;

const CURR_SELECTED_CHIP_STATUS =
(localStorage.getItem('SELECTED_CHIP') as EExtractionStatus) ||
(localStorage.getItem(`SELECTED_CHIP-${projectId}`) as EExtractionStatus) ||
EExtractionStatus.UNCATEGORIZED;

const currStudyIndex = (studyset.studies || []).findIndex((study) => study === studyId);
Expand All @@ -77,13 +77,13 @@ const EditStudyToolbar: React.FC = (props) => {
if (aStudyStatus === CURR_SELECTED_CHIP_STATUS) return aStudyId;
}
return undefined;
}, [studyId, studyStatusList, studyset]);
}, [projectId, studyId, studyStatusList, studyset]);

const getValidNextStudyId = useCallback((): string | undefined => {
if (!studyset?.studies) return undefined;

const CURR_SELECTED_CHIP_STATUS =
(localStorage.getItem('SELECTED_CHIP') as EExtractionStatus) ||
(localStorage.getItem(`SELECTED_CHIP-${projectId}`) as EExtractionStatus) ||
EExtractionStatus.UNCATEGORIZED;
const currStudyIndex = (studyset.studies || []).findIndex((study) => study === studyId);
if (currStudyIndex < 0) {
Expand All @@ -105,7 +105,7 @@ const EditStudyToolbar: React.FC = (props) => {
}
}
return undefined;
}, [studyId, studyStatusList, studyset]);
}, [projectId, studyId, studyStatusList, studyset]);

const handleMoveToPreviousStudy = () => {
const prevId = getValidPrevStudyId();
Expand Down Expand Up @@ -163,13 +163,13 @@ const EditStudyToolbar: React.FC = (props) => {
}, [getValidNextStudyId]);

const currSelectedChipText = useMemo(() => {
const currSelectedChip = (localStorage.getItem('SELECTED_CHIP') ||
const currSelectedChip = (localStorage.getItem(`SELECTED_CHIP-${projectId}`) ||
EExtractionStatus.UNCATEGORIZED) as EExtractionStatus;
return getCurrSelectedChipText(currSelectedChip);
}, []);
}, [projectId]);

const prevNextArrowColor = useMemo(() => {
const currSelectedChip = (localStorage.getItem('SELECTED_CHIP') ||
const currSelectedChip = (localStorage.getItem(`SELECTED_CHIP-${projectId}`) ||
EExtractionStatus.UNCATEGORIZED) as EExtractionStatus;
switch (currSelectedChip) {
case EExtractionStatus.UNCATEGORIZED:
Expand All @@ -181,7 +181,7 @@ const EditStudyToolbar: React.FC = (props) => {
default:
return 'warning.main';
}
}, []);
}, [projectId]);

return (
<Box sx={EditStudyToolbarStyles.stickyContainer}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import { useEffect, useMemo, useState } from 'react';
import { useHistory, useParams } from 'react-router-dom';
import { FixedSizeList, ListChildComponentProps } from 'react-window';

const selectedChipLocalStorageKey = 'SELECTED_CHIP';

export enum EExtractionStatus {
'COMPLETED' = 'completed',
'SAVEDFORLATER' = 'savedforlater',
Expand Down Expand Up @@ -74,6 +72,7 @@ const ExtractionPage: React.FC = (props) => {
const { mutate } = useUpdateStudyset();

const [fieldBeingUpdated, setFieldBeingUpdated] = useState('');
const selectedChipLocalStorageKey = `SELECTED_CHIP-${projectId}`;
const selectedChipInLocalStorage =
(localStorage.getItem(selectedChipLocalStorageKey) as EExtractionStatus) ||
EExtractionStatus.UNCATEGORIZED;
Expand Down

0 comments on commit e1203ae

Please sign in to comment.