diff options
author | Alexander NeonXP Kiryukhin <a.kiryukhin@mail.ru> | 2019-05-15 03:32:55 +0300 |
---|---|---|
committer | Alexander NeonXP Kiryukhin <a.kiryukhin@mail.ru> | 2019-05-15 03:32:55 +0300 |
commit | 491a92f71cf13bc8ef84db3b7fb24361013afb8e (patch) | |
tree | f4d45203428dcafa0b865e3604f5e9479d2c150b /src/Api | |
parent | 0c9db775302d15483385f0621611583e3a2407cd (diff) |
Many fixes
Diffstat (limited to 'src/Api')
-rw-r--r-- | src/Api/api.ts | 16 | ||||
-rw-r--r-- | src/Api/interfaces.ts | 4 |
2 files changed, 9 insertions, 11 deletions
diff --git a/src/Api/api.ts b/src/Api/api.ts index 2da4594..4c83252 100644 --- a/src/Api/api.ts +++ b/src/Api/api.ts @@ -59,8 +59,7 @@ export const getTilesToLoad = (region: Region, width: number): string[] => { return tilesToLoad } -export const loadTiles = async (tilesToLoad: string[], params: RequestParams): Promise<LoadedResult> => { - const chunk = tilesToLoad.splice(0, 25) +export const loadTiles = async (tilesToLoad: string[], params: RequestParams): Promise<{ result: LoadedResult, failed: string[] }> => { const loadedData: LoadedResult = { fields: {}, links: {}, @@ -68,10 +67,9 @@ export const loadTiles = async (tilesToLoad: string[], params: RequestParams): P portalsByTile: {}, fieldsByTile: {}, linksByTile: {}, - failedTiles: tilesToLoad, - loaded: false, } - await getEntities(chunk, params) + const failed = [] + await getEntities(tilesToLoad, params) .then(loaded => { const result = loaded.result if (!result || !result['map']) { @@ -79,7 +77,7 @@ export const loadTiles = async (tilesToLoad: string[], params: RequestParams): P } return Object.keys(result['map']).map(tile => { if (result['map'][tile]['error'] || !result['map'][tile]['gameEntities']) { - loadedData.failedTiles.push(tile) + failed.push(tile) return true } if (!loadedData.portalsByTile[tile]) { @@ -114,9 +112,11 @@ export const loadTiles = async (tilesToLoad: string[], params: RequestParams): P }) }) }).catch(e => { - loadedData.failedTiles = [...loadedData.failedTiles, ...chunk] + tilesToLoad.forEach(element => { + failed.push(element) + }); }) - return loadedData + return { result: loadedData, failed } } const getBoundingBox = (region: Region): BoundingBox => { diff --git a/src/Api/interfaces.ts b/src/Api/interfaces.ts index 779fcf1..0dcafc0 100644 --- a/src/Api/interfaces.ts +++ b/src/Api/interfaces.ts @@ -32,7 +32,6 @@ export interface GetPortalResponse { } export interface LoadedResult { - loaded: boolean, portalsByTile: { [tile: string]: string[] }, @@ -50,8 +49,7 @@ export interface LoadedResult { }, fields: { [guid: string]: Field - }, - failedTiles: string[] + } } |