conserve radius of location between Home page & Search page - #1850

This commit is contained in:
Laurent GAY
2025-10-07 16:50:38 +02:00
parent c2dff26afa
commit 9886931f97
3 changed files with 42 additions and 3 deletions

View File

@@ -84,7 +84,9 @@ import { AddressSearchType, ContentType } from "@/types/enums";
import {
addressToLocation,
getAddressFromLocal,
getRadiusFromLocal,
storeAddressInLocal,
storeRadiusInLocal,
} from "@/utils/location";
import { computed, defineAsyncComponent } from "vue";
import { useI18n } from "vue-i18n";
@@ -145,11 +147,20 @@ const search = computed({
});
const distance = computed({
get(): number {
return props.distance;
get(): number | null {
if (props.distance) {
return props.distance;
}
if (props.fromLocalStorage) {
return getRadiusFromLocal();
}
return null;
},
set(newDistance: number) {
emit("update:distance", newDistance);
if (props.fromLocalStorage) {
storeRadiusInLocal(newDistance);
}
},
});