Auto deploy: 2025-12-09 03:51:13
This commit is contained in:
parent
c755c0c9c0
commit
9814fc411a
|
|
@ -306,7 +306,7 @@ export default function MapView() {
|
||||||
}
|
}
|
||||||
}, [mainFilter, bottomCategories, subFilter]);
|
}, [mainFilter, bottomCategories, subFilter]);
|
||||||
|
|
||||||
/* ------------ FACTEUR EN COMMUN: CREATION D'UN MARKER POUR UN POST -------------- */
|
/* ------------ FACTEUR COMMUN: CREATION D'UN MARKER POUR UN POST -------------- */
|
||||||
const createMarkerForPost = (post) => {
|
const createMarkerForPost = (post) => {
|
||||||
const map = mapRef.current;
|
const map = mapRef.current;
|
||||||
if (!map) return;
|
if (!map) return;
|
||||||
|
|
@ -432,7 +432,8 @@ export default function MapView() {
|
||||||
|
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
|
|
||||||
// ici on recharge la vue => on enlève tout puis on remet
|
// *** ICI: les filtres contrôlent TOUT ***
|
||||||
|
// On efface tous les markers, et on remet EXACTEMENT ce que le backend renvoie.
|
||||||
markersRef.current.forEach((m) => m.marker.remove());
|
markersRef.current.forEach((m) => m.marker.remove());
|
||||||
markersRef.current = [];
|
markersRef.current = [];
|
||||||
expandedElRef.current = null;
|
expandedElRef.current = null;
|
||||||
|
|
@ -479,13 +480,18 @@ export default function MapView() {
|
||||||
if (msg.type === "new_post" && msg.post) {
|
if (msg.type === "new_post" && msg.post) {
|
||||||
const p = msg.post;
|
const p = msg.post;
|
||||||
|
|
||||||
// Optionnel: respecter les filtres actuels
|
// Respecte les filtres actuels
|
||||||
|
|
||||||
|
// 1) CATEGORY
|
||||||
const catCode = categoryCode(mainFilter);
|
const catCode = categoryCode(mainFilter);
|
||||||
if (catCode && p.category && p.category.toUpperCase() !== catCode) {
|
if (catCode && p.category && p.category.toUpperCase() !== catCode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position: ne l'afficher que s'il est dans le rayon courant
|
// 2) TIME filter : on fait confiance au backend (p.created_at récent)
|
||||||
|
// Si ton backend ne renvoie pas created_at, on laisse passer.
|
||||||
|
|
||||||
|
// 3) ZONE: ne l'afficher que s'il est dans le rayon courant
|
||||||
if (viewParams.center && viewParams.radiusKm) {
|
if (viewParams.center && viewParams.radiusKm) {
|
||||||
const coords = getCoords(p);
|
const coords = getCoords(p);
|
||||||
if (coords) {
|
if (coords) {
|
||||||
|
|
@ -516,7 +522,7 @@ export default function MapView() {
|
||||||
ws.close();
|
ws.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [mainFilter, viewParams]);
|
}, [mainFilter, timeFilter, viewParams]);
|
||||||
|
|
||||||
/* ------------ ACTIONS UI -------------- */
|
/* ------------ ACTIONS UI -------------- */
|
||||||
|
|
||||||
|
|
@ -597,7 +603,7 @@ export default function MapView() {
|
||||||
await createPost(payload);
|
await createPost(payload);
|
||||||
setIsSaving(false);
|
setIsSaving(false);
|
||||||
setIsCreating(false);
|
setIsCreating(false);
|
||||||
// On ne refetch pas tout ici, on laisse le WS rajouter le nouveau
|
// On laisse le WS rajouter le nouveau
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("createPost error:", e);
|
console.error("createPost error:", e);
|
||||||
setIsSaving(false);
|
setIsSaving(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue