Skip to content

Commit

Permalink
base modes cleanup
Browse files Browse the repository at this point in the history
-remove unused imports

-fix missing type "BaseModeKey"
--this was previously `keyof typeof BASE_MODES`. Now that BASE_MODES is in e-mission-common and is defined as a `dict`, Typescript has a harder time picking up on the types. Keeping as `string` for now.
  • Loading branch information
JGreenlee committed Aug 16, 2024
1 parent 9d57af9 commit b1cd24a
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 7 deletions.
1 change: 0 additions & 1 deletion www/js/diary/cards/ModesIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { View, StyleSheet } from 'react-native';
import color from 'color';
import TimelineContext from '../../TimelineContext';
import { logDebug } from '../../plugin/logger';
import { getBaseModeByValue } from '../diaryHelper';
import { Text, Icon, useTheme } from 'react-native-paper';
import { useTranslation } from 'react-i18next';
import { base_modes } from 'e-mission-common';
Expand Down
1 change: 0 additions & 1 deletion www/js/diary/details/TripSectionsDescriptives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useContext } from 'react';
import { View, StyleSheet } from 'react-native';
import { Icon, Text, useTheme } from 'react-native-paper';
import useDerivedProperties from '../useDerivedProperties';
import { getBaseModeByValue } from '../diaryHelper';
import TimelineContext from '../../TimelineContext';
import { base_modes } from 'e-mission-common';

Expand Down
4 changes: 1 addition & 3 deletions www/js/diary/diaryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AppConfig } from '../types/appConfigTypes';
import { ImperialConfig } from '../config/useImperialConfig';
import { base_modes } from 'e-mission-common';

export const modeColors = base_modes.mode_colors;
export type BaseModeKey = string; // TODO figure out how to get keyof typeof base_modes.BASE_MODES

// parallels the server-side MotionTypes enum: https://github.com/e-mission/e-mission-server/blob/94e7478e627fa8c171323662f951c611c0993031/emission/core/wrapper/motionactivity.py#L12
export type MotionTypeKey =
Expand All @@ -27,8 +27,6 @@ export type MotionTypeKey =
| 'STOPPED_WHILE_IN_VEHICLE'
| 'AIR_OR_HSR';

const BaseModes = base_modes.BASE_MODES;

export function getBaseModeByValue(value: string, labelOptions: LabelOptions) {
const modeOption = labelOptions?.MODE?.find((opt) => opt.value == value);
return base_modes.get_base_mode_by_key(modeOption?.baseMode || 'OTHER');
Expand Down
1 change: 0 additions & 1 deletion www/js/diary/timelineHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { displayError, displayErrorMsg, logDebug } from '../plugin/logger';
import { getBaseModeByValue } from './diaryHelper';
import { getUnifiedDataForInterval } from '../services/unifiedDataLoader';
import { getRawEntries } from '../services/commHelper';
import { ServerResponse, BEMData } from '../types/serverData';
Expand Down
2 changes: 1 addition & 1 deletion www/js/metrics/MetricsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import ToggleSwitch from '../components/ToggleSwitch';
import { cardStyles } from './MetricsTab';
import { labelKeyToRichMode, labelOptions } from '../survey/multilabel/confirmHelper';
import { getBaseModeByText, modeColors } from '../diary/diaryHelper';
import { getBaseModeByText } from '../diary/diaryHelper';
import { useTranslation } from 'react-i18next';
import { GroupingField, MetricName } from '../types/appConfigTypes';
import { useImperialConfig } from '../config/useImperialConfig';
Expand Down

0 comments on commit b1cd24a

Please sign in to comment.