summaryrefslogtreecommitdiff
path: root/src/Actions/entity.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/Actions/entity.ts')
-rw-r--r--src/Actions/entity.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Actions/entity.ts b/src/Actions/entity.ts
index d373d9d..d23022a 100644
--- a/src/Actions/entity.ts
+++ b/src/Actions/entity.ts
@@ -3,7 +3,6 @@ import { Dispatch, Store } from 'redux';
import { Region } from 'react-native-maps';
import { getTilesToLoad, loadTiles, getPortalDetails } from '../Api/api';
import { Portal, Link, Field } from '../Api/types';
-import { LoadedResult } from '../Api/interfaces';
import { decodePortal } from '../Api/entityDecoder';
const entity = {
@@ -46,10 +45,20 @@ const entity = {
const store = getStore()
const { v, csrf } = store.auth
const params = { v, csrf }
- getPortalDetails(guid, params).then(j => {
+ getPortalDetails(guid, params).then(async j => {
const portal = decodePortal(j.result)
portal.fullLoad = true
dispatch(entity.portalSet(guid, portal))
+ let addr = "нет"
+ try {
+ addr = await fetch(`https://nominatim.openstreetmap.org/reverse?format=json&polygon_geojson=1&lat=${portal.coords.latitude}&lon=${portal.coords.longitude}`)
+ .then(r => r.json())
+ .then(j => [j.address.city, j.address.road, j.address.house_number].filter(p => !!p).join(', ') || 'нет')
+ } catch (e) {
+ addr = "ошибка"
+ }
+ portal.address = addr
+ dispatch(entity.portalSet(guid, portal))
})
},
'setLoadQueue': (queue: string[][]) => ({