Commit fdce3523 authored by gabrielweich's avatar gabrielweich
Browse files

melhora performance da listagem de espaço atraves da paralelizacao de requisicoes ao firebase

1 merge request!33Fix/ Melhora performance da listagem de espaço atraves da paralelizacao de requisicoes ao firebase
Showing with 9 additions and 10 deletions
+9 -10
......@@ -59,9 +59,13 @@ const ListPlaces: React.FC<ListPlacesPageProps> = ({ navigation, route }) => {
setPeople(params.people);
let list = await PlacesService.searchPlaces(params);
for (let i = 0; i < list.length; i++) {
list[i].imageURL = await PlacesService.retrieveThumbnails(list[i].spaceId);
}
const images = await Promise.all(list.map(place => PlacesService.retrieveThumbnails(place.spaceId)))
list.forEach((place, i) => {
place.imageURL = images[i]
})
setInputs(list);
}
})();
......
......@@ -54,19 +54,14 @@ class PlacesService {
.ref("spaces/" + id + "/photos/thumbnail/")
.listAll()
.then(async (results) => {
let urls: string[] = [];
for (let i = 0; i < results.items.length; i++) {
await results.items[i].getDownloadURL().then((url) => {
urls.push(url);
});
}
const urls: string[] = await Promise.all(results.items.map((item, i) => results.items[i].getDownloadURL()))
return urls;
});
return thumbnails;
};
/*
// Retrieves a filtered list of listing objects
// Retrieves a filtered list of listing objects
// @param values, the filter parameters to be used
*/
public async searchPlaces(values: SearchParams) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment