|
@@ -389,26 +389,37 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (seriesIcons) {
|
|
|
- let loadedSeriesImages: any = {};
|
|
|
-
|
|
|
- seriesIcons.data.forEach(async (icon) => {
|
|
|
- const id = icon.id;
|
|
|
- const img = API_HOST + '/static/img/series_new2/' + icon.new_icon_png;
|
|
|
- const imgVisited = API_HOST + '/static/img/series_new2/' + icon.new_icon_visited_png;
|
|
|
- if (icon.new_icon_png && icon.new_icon_visited_png) {
|
|
|
- loadedSeriesImages[id] = { uri: img };
|
|
|
- loadedSeriesImages[`${id}v`] = { uri: imgVisited };
|
|
|
+ const loadImages = async () => {
|
|
|
+ const loadedSeriesImages: Record<string, { uri: string }> = {};
|
|
|
+ const prefetchUrls: string[] = [];
|
|
|
+
|
|
|
+ const promises = seriesIcons.data.map(async (icon) => {
|
|
|
+ const id = icon.id;
|
|
|
+ const img = `${API_HOST}/static/img/series_new2_small/${icon.new_icon_png}`;
|
|
|
+ const imgVisited = `${API_HOST}/static/img/series_new2_small/${icon.new_icon_visited_png}`;
|
|
|
+
|
|
|
+ if (icon.new_icon_png && icon.new_icon_visited_png && !images[id] && !images[`${id}v`]) {
|
|
|
+ loadedSeriesImages[id] = { uri: img };
|
|
|
+ loadedSeriesImages[`${id}v`] = { uri: imgVisited };
|
|
|
+
|
|
|
+ const cachedUrl = await ExpoImage.getCachePathAsync(img);
|
|
|
+ const cachedUrlVisited = await ExpoImage.getCachePathAsync(imgVisited);
|
|
|
+
|
|
|
+ if (!cachedUrl) prefetchUrls.push(img);
|
|
|
+ if (!cachedUrlVisited) prefetchUrls.push(imgVisited);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- const cachedUrl = await ExpoImage.getCachePathAsync(img);
|
|
|
- const cachedUrlVisited = await ExpoImage.getCachePathAsync(imgVisited);
|
|
|
+ await Promise.all(promises);
|
|
|
|
|
|
- if (!cachedUrl || !cachedUrlVisited) {
|
|
|
- ExpoImage.prefetch([img, imgVisited]);
|
|
|
- }
|
|
|
+ if (prefetchUrls.length > 0) {
|
|
|
+ ExpoImage.prefetch(prefetchUrls);
|
|
|
}
|
|
|
- });
|
|
|
|
|
|
- setImages((prevImages: any) => ({ ...prevImages, ...loadedSeriesImages }));
|
|
|
+ setImages((prevImages: any) => ({ ...prevImages, ...loadedSeriesImages }));
|
|
|
+ };
|
|
|
+
|
|
|
+ loadImages();
|
|
|
}
|
|
|
}, [seriesIcons]);
|
|
|
|
|
@@ -1253,7 +1264,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
style={{
|
|
|
symbolSpacing: 1,
|
|
|
iconImage: ['get', 'series_id'],
|
|
|
- iconSize: 0.18,
|
|
|
+ iconSize: 0.51,
|
|
|
iconAllowOverlap: true,
|
|
|
iconIgnorePlacement: true,
|
|
|
visibility: 'visible',
|
|
@@ -1280,7 +1291,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
style={{
|
|
|
symbolSpacing: 1,
|
|
|
iconImage: '{series_id}v',
|
|
|
- iconSize: 0.18,
|
|
|
+ iconSize: 0.51,
|
|
|
iconAllowOverlap: true,
|
|
|
iconIgnorePlacement: true,
|
|
|
visibility: 'visible',
|