From 41be0e63626af482d71fd3aa99941b21238b92d4 Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Tue, 28 Jun 2022 12:10:46 +0200 Subject: [PATCH] :bug: Fix default values for modules The default value was not set correctly for modules. This has been fixed. It was also fixed in the Weather Module and the Date Module. --- src/components/modules/date/DateModule.tsx | 2 +- src/components/modules/moduleWrapper.tsx | 17 +++++++++++++---- .../modules/weather/WeatherModule.tsx | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/components/modules/date/DateModule.tsx b/src/components/modules/date/DateModule.tsx index ad5991736..3e212af83 100644 --- a/src/components/modules/date/DateModule.tsx +++ b/src/components/modules/date/DateModule.tsx @@ -23,7 +23,7 @@ export default function DateComponent(props: any) { const [date, setDate] = useState(new Date()); const setSafeInterval = useSetSafeInterval(); const { config } = useConfig(); - const isFullTime = config?.modules?.[DateModule.title]?.options?.full?.value ?? false; + const isFullTime = config?.modules?.[DateModule.title]?.options?.full?.value ?? true; const formatString = isFullTime ? 'HH:mm' : 'h:mm A'; // Change date on minute change // Note: Using 10 000ms instead of 1000ms to chill a little :) diff --git a/src/components/modules/moduleWrapper.tsx b/src/components/modules/moduleWrapper.tsx index c7423f658..6bbd69c86 100644 --- a/src/components/modules/moduleWrapper.tsx +++ b/src/components/modules/moduleWrapper.tsx @@ -28,8 +28,11 @@ function getItems(module: IModule) { { setConfig({ @@ -81,7 +84,11 @@ function getItems(module: IModule) { id={optionName} name={optionName} label={values[index].name} - defaultValue={(moduleInConfig?.options?.[keys[index]]?.value as string) ?? ''} + defaultValue={ + (moduleInConfig?.options?.[keys[index]]?.value as string) ?? + (values[index].value as string) ?? + '' + } onChange={(e) => {}} /> @@ -96,7 +103,9 @@ function getItems(module: IModule) { { diff --git a/src/components/modules/weather/WeatherModule.tsx b/src/components/modules/weather/WeatherModule.tsx index 1d2a522a0..8a6f6c98f 100644 --- a/src/components/modules/weather/WeatherModule.tsx +++ b/src/components/modules/weather/WeatherModule.tsx @@ -29,7 +29,7 @@ export const WeatherModule: IModule = { }, location: { name: 'Current location', - value: '', + value: 'Paris', }, }, }; @@ -135,7 +135,7 @@ export default function WeatherComponent(props: any) { const { config } = useConfig(); const [weather, setWeather] = useState({} as WeatherResponse); const cityInput: string = - (config?.modules?.[WeatherModule.title]?.options?.location?.value as string) ?? ''; + (config?.modules?.[WeatherModule.title]?.options?.location?.value as string) ?? 'Paris'; const isFahrenheit: boolean = (config?.modules?.[WeatherModule.title]?.options?.freedomunit?.value as boolean) ?? false;