Skip to content

Commit

Permalink
Adding support for new 'resultMeta' object
Browse files Browse the repository at this point in the history
  • Loading branch information
spong committed Oct 31, 2019
1 parent 50edbd8 commit cb0d08d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ export const mockLayerListDouble = [

export const mockMapLayerEventHandlers: MapLayerEventHandlers = {
onDataLoad: ({ layerId, dataId }: OnDataLoadProps) => {},
onDataLoadEnd: ({ layerId, dataId, featuresCount }: OnDataLoadEndProps) => {},
onDataLoadEnd: ({ layerId, dataId, resultMeta }: OnDataLoadEndProps) => {},
onDataLoadError: ({ layerId, dataId, errorMessage }: OnDataLoadErrorProps) => {},
};
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,15 @@ export const useMapLayers = (): Return => {
onDataLoad: ({ layerId, dataId }: OnDataLoadProps) => {
setMapLayers(prevMapLayers => mergeMapLayers(prevMapLayers, dataId, layerId, true));
},
onDataLoadEnd: ({ layerId, dataId, featuresCount }: OnDataLoadEndProps) => {
onDataLoadEnd: ({ layerId, dataId, resultMeta }: OnDataLoadEndProps) => {
setMapLayers(prevMapLayers =>
mergeMapLayers(prevMapLayers, dataId, layerId, false, featuresCount)
mergeMapLayers(
prevMapLayers,
dataId,
layerId,
false,
resultMeta.featuresCount != null ? resultMeta.featuresCount : 0
)
);
},
onDataLoadError: ({ layerId, dataId, errorMessage }: OnDataLoadErrorProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export interface OnDataLoadProps {
export interface OnDataLoadEndProps {
layerId: string;
dataId: string;
featuresCount: number;
resultMeta: {
featuresCount: number;
};
}

export interface OnDataLoadErrorProps {
Expand All @@ -86,7 +88,7 @@ export interface OnDataLoadErrorProps {

export interface MapLayerEventHandlers {
onDataLoad({ layerId, dataId }: OnDataLoadProps): void;
onDataLoadEnd({ layerId, dataId, featuresCount }: OnDataLoadEndProps): void;
onDataLoadEnd({ layerId, dataId, resultMeta }: OnDataLoadEndProps): void;
onDataLoadError({ layerId, dataId, errorMessage }: OnDataLoadErrorProps): void;
}

Expand Down

0 comments on commit cb0d08d

Please sign in to comment.