diff --git a/src/api/client.js b/src/api/client.js index ec103d6..cc335ba 100644 --- a/src/api/client.js +++ b/src/api/client.js @@ -175,10 +175,28 @@ export async function fetchPosts(filters = {}) { if (filters.subCategory) params.set("sub_category", filters.subCategory); if (filters.time) params.set("time", filters.time); if (filters.username) params.set("username", filters.username); - if (typeof filters.lat === "number") params.set("lat", String(filters.lat)); - if (typeof filters.lon === "number") params.set("lon", String(filters.lon)); + + // Validate and set lat/lon with proper bounds checking + if (typeof filters.lat === "number") { + if (filters.lat >= -90 && filters.lat <= 90) { + params.set("lat", String(filters.lat)); + } else { + console.warn("Invalid latitude value (must be -90 to 90):", filters.lat); + } + } + if (typeof filters.lon === "number") { + if (filters.lon >= -180 && filters.lon <= 180) { + params.set("lon", String(filters.lon)); + } else { + console.warn("Invalid longitude value (must be -180 to 180):", filters.lon); + } + } if (typeof filters.radiusKm === "number") { - params.set("radius_km", String(filters.radiusKm)); + if (filters.radiusKm > 0 && filters.radiusKm <= 20000) { + params.set("radius_km", String(filters.radiusKm)); + } else { + console.warn("Invalid radius value (must be > 0 and <= 20000 km):", filters.radiusKm); + } } if (typeof filters.limit === "number" && filters.limit > 0) { params.set("limit", String(filters.limit)); diff --git a/src/components/Map/MapView.jsx b/src/components/Map/MapView.jsx index 3bdbcf8..c9af256 100644 --- a/src/components/Map/MapView.jsx +++ b/src/components/Map/MapView.jsx @@ -1279,7 +1279,7 @@ export default function MapView({ if (!imageTouched) { if (image && !isPlaceholder) { setUseCustomImage(true); - if (!draftImageFile && !draftImagePreview) { + if (!draftImageFile && (!draftImagePreview || draftImagePreview === LINK_PREVIEW_PLACEHOLDER)) { addMediaUrlToGallery(image); } } else { @@ -1456,10 +1456,10 @@ export default function MapView({ const galleryItems = draftMediaUrls.filter( (url) => url && url !== LINK_PREVIEW_PLACEHOLDER ); - const galleryThumbnails = galleryItems.slice( - galleryPreviewImage ? 1 : 0 - ); + const hasCustomImages = galleryItems.length > 0; const isLinkMode = contentMode === "link"; + const shouldShowPreviewCard = isLinkMode; + const galleryThumbnails = shouldShowPreviewCard ? galleryItems.slice(1) : galleryItems; return (
@@ -1712,17 +1712,22 @@ export default function MapView({ )} {createStep === 2 && ( <> - {galleryPreviewImage && ( -
- Link preview -
- {draftSource ? {draftSource} : null} - {draftPublishedAt ? ( - {formatPreviewDate(draftPublishedAt)} - ) : null} -
+ {shouldShowPreviewCard && ( +
+ Post preview +
+ {draftSource ? {draftSource} : null} + {draftPublishedAt ? ( + {formatPreviewDate(draftPublishedAt)} + ) : null} +
+
+ )} {galleryThumbnails.length > 0 && ( -
+
{galleryThumbnails.map((url, idx) => (
)} -
- )}