Improving TrkSegViewer

This commit is contained in:
vdv committed 2023-01-07 18:46:14 +01:00
1 parent 7483d9f904
commit 1f2979b28b
6 files changed
+51 -14

No files matched your search

@@ -8,7 +8,7 @@ import { useI18n } from '@solid-primitives/i18n';
import dispatch from '../../workers/dispatcher-main';
interface Props {
target: any;
target: () => any;
putAction: string;
putParamName: string;
}
@@ -20,14 +20,14 @@ const DisplayOrGetAddress: Component<Props> = ({
}) => {
const [t, { add, locale, dict }] = useI18n();
const findClickHandlerFactory = (target: any) => async () => {
const address = await findAddress(target.$.lon, target.$.lat, locale);
const updatedTarget = cloneDeep(target);
const findClickHandler = async () => {
const address = await findAddress(target().$.lon, target().$.lat, locale);
const updatedTarget = cloneDeep(target());
if (updatedTarget.extensions === undefined) {
updatedTarget.extensions = {};
}
updatedTarget.extensions.address = address;
const params: any = { id: target.id };
const params: any = { id: target().id };
params[putParamName] = updatedTarget;
dispatch({
action: putAction,
@@ -37,14 +37,14 @@ const DisplayOrGetAddress: Component<Props> = ({
return (
<Show
when={target.extensions?.address}
when={target().extensions?.address}
fallback={
<IconButton color='primary' onClick={findClickHandlerFactory(target)}>
<IconButton color='primary' onClick={findClickHandler}>
<SearchIcon />
</IconButton>
}
>
<>{getVillageOrTown(target.extensions?.address)}</>
<>{getVillageOrTown(target().extensions?.address)}</>
</Show>
);
};