Improve website loading speed by optimizing image data retrieval
Fetch limited sets of gallery images for the homepage and widgets to reduce initial load times and bandwidth usage. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1f7e7e89-a520-4970-9645-37daadc466dc Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: de3b3f76-575a-4b3d-8981-d81d7b9356ee Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/1f7e7e89-a520-4970-9645-37daadc466dc/NJvOVoB Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
9ceb2526a3
commit
935f307fa4
@ -225,7 +225,8 @@ function SingleImageCarousel({
|
||||
|
||||
export function PhotoGalleryWidget({ reverseOrder = false }: { reverseOrder?: boolean } = {}) {
|
||||
const { data: rawImages, isLoading } = useQuery<GalleryImage[]>({
|
||||
queryKey: ["/api/gallery"],
|
||||
queryKey: ["/api/gallery", "widget"],
|
||||
queryFn: () => fetch("/api/gallery?limit=30").then((r) => r.json()),
|
||||
});
|
||||
const images = reverseOrder && rawImages ? [...rawImages].reverse() : rawImages;
|
||||
|
||||
|
||||
@ -493,7 +493,8 @@ export default function Home() {
|
||||
});
|
||||
|
||||
const { data: galleryImages } = useQuery<GalleryImage[]>({
|
||||
queryKey: ["/api/gallery"],
|
||||
queryKey: ["/api/gallery", "home"],
|
||||
queryFn: () => fetch("/api/gallery?limit=20").then((r) => r.json()),
|
||||
});
|
||||
|
||||
const focalPoints = useFocalPoints();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -362,7 +362,7 @@ export async function registerRoutes(
|
||||
"6": "Folx Stadl",
|
||||
};
|
||||
|
||||
app.get("/api/gallery", async (_req, res) => {
|
||||
app.get("/api/gallery", async (req, res) => {
|
||||
try {
|
||||
let data: any[] = [];
|
||||
|
||||
@ -387,7 +387,8 @@ export async function registerRoutes(
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
|
||||
}
|
||||
res.json(shuffled);
|
||||
const limit = parseInt(req.query.limit as string) || 0;
|
||||
res.json(limit > 0 ? shuffled.slice(0, limit) : shuffled);
|
||||
} catch (err: any) {
|
||||
res.json([]);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user