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