Map push
This commit is contained in:
@@ -266,7 +266,8 @@ export function subscribeToMapLayers(
|
||||
onShapeChange: (payload: RealtimeMapPayload<MapShape>) => void,
|
||||
) {
|
||||
const layerIdSet = new Set(layerIds);
|
||||
const channel = supabase.channel(`map:${layerIds.join(',')}`);
|
||||
const channelName = `map:${layerIds[0]?.slice(0, 8) ?? 'x'}-${Date.now()}`;
|
||||
const channel = supabase.channel(channelName);
|
||||
|
||||
channel
|
||||
.on('postgres_changes', { event: '*', schema: 'public', table: 'map_pins' },
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
type MapPin as MapPinType,
|
||||
type MapShape,
|
||||
type RealtimeMapPayload,
|
||||
fetchMapLayers,
|
||||
createMapLayer,
|
||||
updateMapLayer,
|
||||
deleteMapLayer,
|
||||
@@ -1118,6 +1119,20 @@
|
||||
await import("leaflet/dist/leaflet.css");
|
||||
L = leaflet.default ?? leaflet;
|
||||
|
||||
// Always fetch fresh data from DB so expand/collapse gets latest state
|
||||
try {
|
||||
const fresh = await fetchMapLayers(supabase, departmentId);
|
||||
if (fresh.length > 0) {
|
||||
layers = fresh;
|
||||
activeLayerIdx = Math.min(activeLayerIdx, layers.length - 1);
|
||||
showLayerOnMap(layers[activeLayerIdx]);
|
||||
setupRealtime();
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
// Fall through to initialLayers or create default
|
||||
}
|
||||
|
||||
if (layers.length === 0) {
|
||||
try {
|
||||
const layer = await createMapLayer(supabase, departmentId, {
|
||||
|
||||
4
supabase/migrations/050_revert_map_replica_identity.sql
Normal file
4
supabase/migrations/050_revert_map_replica_identity.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- Revert REPLICA IDENTITY FULL back to DEFAULT
|
||||
ALTER TABLE map_layers REPLICA IDENTITY DEFAULT;
|
||||
ALTER TABLE map_pins REPLICA IDENTITY DEFAULT;
|
||||
ALTER TABLE map_shapes REPLICA IDENTITY DEFAULT;
|
||||
Reference in New Issue
Block a user