Skip to content

Commit

Permalink
fix label context issue after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jiji14 committed Feb 15, 2024
1 parent 7e09923 commit ae66eff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
5 changes: 1 addition & 4 deletions www/js/diary/LabelTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { fillLocationNamesOfTrip, resetNominatimLimiter } from './addressNamesHe
import { getLabelOptions, labelOptionByValue } from '../survey/multilabel/confirmHelper';
import { displayError, displayErrorMsg, logDebug, logWarn } from '../plugin/logger';
import { useTheme } from 'react-native-paper';
import { getPipelineRangeTs, getUserCustomLabels } from '../services/commHelper';
import { getPipelineRangeTs } from '../services/commHelper';
import { getNotDeletedCandidates, mapInputsToTimelineEntries } from '../survey/inputMatcher';
import { configuredFilters as multilabelConfiguredFilters } from '../survey/multilabel/infinite_scroll_filters';
import { configuredFilters as enketoConfiguredFilters } from '../survey/enketo/infinite_scroll_filters';
Expand Down Expand Up @@ -59,7 +59,6 @@ const LabelTab = () => {
const [displayedEntries, setDisplayedEntries] = useState<TimelineEntry[] | null>(null);
const [refreshTime, setRefreshTime] = useState<Date | null>(null);
const [isLoading, setIsLoading] = useState<string | false>('replace');
const [customLabelMap, setCustomLabelMap] = useState<CustomLabelMap>({});

// initialization, once the appConfig is loaded
useEffect(() => {
Expand Down Expand Up @@ -360,8 +359,6 @@ const LabelTab = () => {
loadAnotherWeek,
loadSpecificWeek,
refresh,
customLabelMap,
setCustomLabelMap,
};

const Tab = createStackNavigator();
Expand Down
2 changes: 0 additions & 2 deletions www/js/diary/LabelTabContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ type ContextProps = {
loadAnotherWeek: any; // TODO
loadSpecificWeek: any; // TODO
refresh: any; // TODO
customLabelMap: CustomLabelMap;
setCustomLabelMap: Dispatch<SetStateAction<CustomLabelMap>>;
};

export default createContext<ContextProps>({} as ContextProps);
12 changes: 3 additions & 9 deletions www/js/survey/multilabel/MultiLabelButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,8 @@ const MultilabelButtonGroup = ({ trip, buttonsInline = false }) => {
const { colors } = useTheme();
const { t } = useTranslation();
const appConfig = useAppConfig();
const {
labelOptions,
labelFor,
userInputFor,
addUserInputToEntry,
customLabelMap,
setCustomLabelMap,
} = useContext(LabelTabContext);
const { labelOptions, labelFor, userInputFor, addUserInputToEntry } = useContext(LabelTabContext);
const { customLabelMap, setCustomLabelMap } = useContext(AppContext);
const { height: windowHeight } = useWindowDimensions();
// modal visible for which input type? (MODE or PURPOSE or REPLACED_MODE, null if not visible)
const [modalVisibleFor, setModalVisibleFor] = useState<MultilabelKey | null>(null);
Expand Down Expand Up @@ -103,7 +97,7 @@ const MultilabelButtonGroup = ({ trip, buttonsInline = false }) => {
(initialLabel && customLabelMap[key].indexOf(initialLabel) > -1) ||
(newLabel && customLabelMap[key].indexOf(newLabel) > -1)
) {
updateUserCustomLabel(key, initialLabel ?? '', newLabel, isOther)
updateUserCustomLabel(key, initialLabel ?? '', newLabel, isOther ?? false)
.then((res) => {
setCustomLabelMap({
...customLabelMap,
Expand Down

0 comments on commit ae66eff

Please sign in to comment.