fix: prevent fetching clusters when no route is selected
This commit is contained in:
@@ -36,6 +36,9 @@ const map = useMap("main");
|
|||||||
watchEffect(async () => {
|
watchEffect(async () => {
|
||||||
const allClusters = [];
|
const allClusters = [];
|
||||||
for (const routeId of store.selectedRouteIds) {
|
for (const routeId of store.selectedRouteIds) {
|
||||||
|
if (routeId === undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const apiClusters = await $fetch<Cluster[]>(
|
const apiClusters = await $fetch<Cluster[]>(
|
||||||
`https://data.mobilites-m.fr/api/routers/default/index/routes/${routeId}/clusters`,
|
`https://data.mobilites-m.fr/api/routers/default/index/routes/${routeId}/clusters`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
const clustersRequest = $fetch<Blob>(
|
||||||
|
"https://pass.mobilites-m.fr/assets/icons/clusters.svg",
|
||||||
|
);
|
||||||
|
|
||||||
|
const image = new Image();
|
||||||
|
const imageLoadPromise = new Promise((resolve) => {
|
||||||
|
image.onload = resolve;
|
||||||
|
});
|
||||||
|
clustersRequest.then((blob) => {
|
||||||
|
image.src = URL.createObjectURL(blob);
|
||||||
|
});
|
||||||
|
await Promise.all([imageLoadPromise, clustersRequest]); // Wait for the image to load
|
||||||
|
|
||||||
|
export const useSvgImage = () => {
|
||||||
|
return useState("cluster.svg", () => image);
|
||||||
|
};
|
||||||
+4
-24
@@ -1,27 +1,7 @@
|
|||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
compatibilityDate: "2025-07-15",
|
compatibilityDate: "2025-07-15",
|
||||||
devtools: { enabled: false },
|
devtools: { enabled: false },
|
||||||
modules: ["@nuxt/eslint", "nuxt-maplibre", "@pinia/nuxt"],
|
modules: ["@nuxt/eslint", "nuxt-maplibre", "@pinia/nuxt"],
|
||||||
vite: {
|
ssr: true,
|
||||||
optimizeDeps: {
|
|
||||||
// noDiscovery: true,
|
|
||||||
// include: ["maplibre-gl"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// hooks: {
|
|
||||||
// "pages:extend"(pages) {
|
|
||||||
// pages.push({
|
|
||||||
// name: "lines",
|
|
||||||
// path: "/lines/",
|
|
||||||
// file: "~/pages/lines/[line_id]/cluster/[cluster_id]/index.vue",
|
|
||||||
// });
|
|
||||||
// pages.push({
|
|
||||||
// name: "line_id",
|
|
||||||
// path: "/lines/:id()",
|
|
||||||
|
|
||||||
// file: "~/pages/lines/[line_id]/cluster/[cluster_id]/index.vue",
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user