From b1cd24a9b42fc4a9e53667917c2a81532b3fe72f Mon Sep 17 00:00:00 2001 From: Jack Greenlee Date: Fri, 16 Aug 2024 13:59:59 -0400 Subject: [PATCH] base modes cleanup -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. --- www/js/diary/cards/ModesIndicator.tsx | 1 - www/js/diary/details/TripSectionsDescriptives.tsx | 1 - www/js/diary/diaryHelper.ts | 4 +--- www/js/diary/timelineHelper.ts | 1 - www/js/metrics/MetricsCard.tsx | 2 +- 5 files changed, 2 insertions(+), 7 deletions(-) diff --git a/www/js/diary/cards/ModesIndicator.tsx b/www/js/diary/cards/ModesIndicator.tsx index 31f649897..8a4cf1689 100644 --- a/www/js/diary/cards/ModesIndicator.tsx +++ b/www/js/diary/cards/ModesIndicator.tsx @@ -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'; diff --git a/www/js/diary/details/TripSectionsDescriptives.tsx b/www/js/diary/details/TripSectionsDescriptives.tsx index b9ecd6dba..4592c838f 100644 --- a/www/js/diary/details/TripSectionsDescriptives.tsx +++ b/www/js/diary/details/TripSectionsDescriptives.tsx @@ -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'; diff --git a/www/js/diary/diaryHelper.ts b/www/js/diary/diaryHelper.ts index 793a61062..505a4b0d1 100644 --- a/www/js/diary/diaryHelper.ts +++ b/www/js/diary/diaryHelper.ts @@ -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 = @@ -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'); diff --git a/www/js/diary/timelineHelper.ts b/www/js/diary/timelineHelper.ts index 7b20f56cf..d4dded91b 100644 --- a/www/js/diary/timelineHelper.ts +++ b/www/js/diary/timelineHelper.ts @@ -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'; diff --git a/www/js/metrics/MetricsCard.tsx b/www/js/metrics/MetricsCard.tsx index c1de9d320..241ab8208 100644 --- a/www/js/metrics/MetricsCard.tsx +++ b/www/js/metrics/MetricsCard.tsx @@ -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';