mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-07-16 17:17:36 +02:00
fixes tile re-rendering after long rate limit periods without having to zoom/pan
This commit is contained in:
@@ -63,6 +63,10 @@ class _MapViewState extends State<MapView> {
|
||||
|
||||
// Ensure initial overlays are fetched
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// Set up tile refresh callback
|
||||
final tileProvider = Provider.of<TileProviderWithCache>(context, listen: false);
|
||||
tileProvider.setOnTilesCachedCallback(_onTilesCached);
|
||||
|
||||
_refreshCamerasFromProvider();
|
||||
});
|
||||
}
|
||||
@@ -72,6 +76,15 @@ class _MapViewState extends State<MapView> {
|
||||
_positionSub?.cancel();
|
||||
_debounce.dispose();
|
||||
_cameraProvider.removeListener(_onCamerasUpdated);
|
||||
|
||||
// Clean up tile refresh callback
|
||||
try {
|
||||
final tileProvider = Provider.of<TileProviderWithCache>(context, listen: false);
|
||||
tileProvider.setOnTilesCachedCallback(null);
|
||||
} catch (e) {
|
||||
// Context might be disposed already - that's okay
|
||||
}
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -79,6 +92,14 @@ class _MapViewState extends State<MapView> {
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
|
||||
void _onTilesCached() {
|
||||
// When new tiles are cached, just trigger a widget rebuild
|
||||
// This should cause the TileLayer to re-render with cached tiles
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
void _refreshCamerasFromProvider() {
|
||||
final appState = context.read<AppState>();
|
||||
LatLngBounds? bounds;
|
||||
@@ -159,6 +180,8 @@ class _MapViewState extends State<MapView> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appState = context.watch<AppState>();
|
||||
|
||||
Reference in New Issue
Block a user