From 491a92f71cf13bc8ef84db3b7fb24361013afb8e Mon Sep 17 00:00:00 2001 From: Alexander NeonXP Kiryukhin Date: Wed, 15 May 2019 03:32:55 +0300 Subject: Many fixes --- src/Api/api.ts | 16 ++++++++-------- src/Api/interfaces.ts | 4 +--- 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src/Api') 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 => { - 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[] + } } -- cgit v1.2.3