blehh
This commit is contained in:
parent
71d38a5163
commit
68c3648768
|
|
@ -22,16 +22,21 @@ export function usePostsEngine({
|
||||||
const [loadingPosts, setLoadingPosts] = useState(false);
|
const [loadingPosts, setLoadingPosts] = useState(false);
|
||||||
const [loadError, setLoadError] = useState("");
|
const [loadError, setLoadError] = useState("");
|
||||||
|
|
||||||
|
const isExpandedOpen = () => {
|
||||||
|
try {
|
||||||
|
return !!expandedElRef?.current;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const rebuildMarkersForFilters = useCallback(
|
const rebuildMarkersForFilters = useCallback(
|
||||||
(tf) => {
|
(tf) => {
|
||||||
const map = mapRef.current;
|
const map = mapRef.current;
|
||||||
if (!map) return;
|
if (!map) return;
|
||||||
|
|
||||||
// If expanded is open and we are inside ignore window, do not rebuild (it closes the popup)
|
// ✅ If expanded overlay/popup is open: NEVER rebuild markers (it closes the expanded)
|
||||||
try {
|
if (isExpandedOpen()) return;
|
||||||
const until = map.__swIgnoreRebuildUntil || 0;
|
|
||||||
if (expandedElRef?.current && until && Date.now() < until) return;
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
clearAllMarkers(markersRef, expandedElRef);
|
clearAllMarkers(markersRef, expandedElRef);
|
||||||
|
|
||||||
|
|
@ -57,6 +62,7 @@ export function usePostsEngine({
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// ✅ Sociowall list can still update via visiblePosts; markers rebuild is blocked while expanded open.
|
||||||
rebuildMarkersForFilters(timeFilter);
|
rebuildMarkersForFilters(timeFilter);
|
||||||
}, [timeFilter, mainFilter, subFilter, rebuildMarkersForFilters]);
|
}, [timeFilter, mainFilter, subFilter, rebuildMarkersForFilters]);
|
||||||
|
|
||||||
|
|
@ -68,18 +74,12 @@ export function usePostsEngine({
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
const mapObj = mapRef.current;
|
// ✅ If expanded is open: delay fetch indefinitely until user closes it
|
||||||
|
if (isExpandedOpen()) {
|
||||||
// Delay fetch while popup is open (prevents marker clear/rebuild)
|
if (delayedFetchRef.current) clearTimeout(delayedFetchRef.current);
|
||||||
try {
|
delayedFetchRef.current = setTimeout(load, 1200);
|
||||||
const until = mapObj?.__swIgnoreFetchUntil || 0;
|
return;
|
||||||
if (until && Date.now() < until) {
|
}
|
||||||
const wait = Math.min(4000, until - Date.now());
|
|
||||||
if (delayedFetchRef.current) clearTimeout(delayedFetchRef.current);
|
|
||||||
delayedFetchRef.current = setTimeout(load, wait + 25);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
const [lng, lat] = viewParams.center;
|
const [lng, lat] = viewParams.center;
|
||||||
const radiusKm = viewParams.radiusKm || 750;
|
const radiusKm = viewParams.radiusKm || 750;
|
||||||
|
|
@ -93,7 +93,6 @@ export function usePostsEngine({
|
||||||
|
|
||||||
const lastR = last.radiusKm || 0;
|
const lastR = last.radiusKm || 0;
|
||||||
const radiusChanged = !lastR || Math.abs(radiusKm - lastR) / Math.max(lastR, 1) >= 0.25;
|
const radiusChanged = !lastR || Math.abs(radiusKm - lastR) / Math.max(lastR, 1) >= 0.25;
|
||||||
|
|
||||||
const minMoveKm = Math.max(50, radiusKm * 0.25);
|
const minMoveKm = Math.max(50, radiusKm * 0.25);
|
||||||
|
|
||||||
if (!radiusChanged && distKm < minMoveKm) return;
|
if (!radiusChanged && distKm < minMoveKm) return;
|
||||||
|
|
@ -133,7 +132,9 @@ export function usePostsEngine({
|
||||||
allPostsRef.current = Array.from(byId.values());
|
allPostsRef.current = Array.from(byId.values());
|
||||||
lastFetchRef.current = { center: [...viewParams.center], radiusKm, filterKey };
|
lastFetchRef.current = { center: [...viewParams.center], radiusKm, filterKey };
|
||||||
|
|
||||||
rebuildMarkersForFilters(timeFilter);
|
// ✅ rebuild markers only if expanded is NOT open (double-safety)
|
||||||
|
if (!isExpandedOpen()) rebuildMarkersForFilters(timeFilter);
|
||||||
|
|
||||||
setLoadingPosts(false);
|
setLoadingPosts(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Erreur chargement posts:", err);
|
console.error("Erreur chargement posts:", err);
|
||||||
|
|
@ -149,7 +150,9 @@ export function usePostsEngine({
|
||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
if (delayedFetchRef.current) {
|
if (delayedFetchRef.current) {
|
||||||
try { clearTimeout(delayedFetchRef.current); } catch {}
|
try {
|
||||||
|
clearTimeout(delayedFetchRef.current);
|
||||||
|
} catch {}
|
||||||
delayedFetchRef.current = null;
|
delayedFetchRef.current = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,9 @@
|
||||||
display:flex; flex-direction:column; gap:.5rem;
|
display:flex; flex-direction:column; gap:.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ✅ Sub-categories row MUST stay above the Sociowall overlap
|
/* ✅ sub-cats: keep above wall overlap + moved DOWN by 10px more */
|
||||||
✅ And move DOWN by ~10px (less bottom padding) */
|
|
||||||
.map-overlay-bottom{
|
.map-overlay-bottom{
|
||||||
bottom: calc(2.6rem + var(--sw-below-overlap, 0px) + env(safe-area-inset-bottom));
|
bottom: calc(2.6rem + var(--sw-below-overlap, 0px) + env(safe-area-inset-bottom) - 20px);
|
||||||
left:50%;
|
left:50%;
|
||||||
transform:translateX(-50%);
|
transform:translateX(-50%);
|
||||||
display:flex;
|
display:flex;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue