mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(mobile): debounce map layer update (#6861)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
f4ab5d3ff7
commit
1d93889920
2 changed files with 15 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
|
@ -6,6 +7,8 @@ import 'package:immich_mobile/modules/map/utils/map_utils.dart';
|
|||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
|
||||
extension MapMarkers on MaplibreMapController {
|
||||
static var _completer = Completer()..complete();
|
||||
|
||||
Future<void> addGeoJSONSourceForMarkers(List<MapMarker> markers) async {
|
||||
return addSource(
|
||||
MapUtils.defaultSourceId,
|
||||
|
|
@ -16,6 +19,12 @@ extension MapMarkers on MaplibreMapController {
|
|||
}
|
||||
|
||||
Future<void> reloadAllLayersForMarkers(List<MapMarker> markers) async {
|
||||
// Wait for previous reload to complete
|
||||
if (!_completer.isCompleted) {
|
||||
return _completer.future;
|
||||
}
|
||||
_completer = Completer();
|
||||
|
||||
// !! Make sure to remove layers before sources else the native
|
||||
// maplibre library would crash when removing the source saying that
|
||||
// the source is still in use
|
||||
|
|
@ -36,6 +45,8 @@ extension MapMarkers on MaplibreMapController {
|
|||
MapUtils.defaultHeatMapLayerId,
|
||||
MapUtils.defaultHeatMapLayerProperties,
|
||||
);
|
||||
|
||||
_completer.complete();
|
||||
}
|
||||
|
||||
Future<Symbol?> addMarkerAtLatLng(LatLng centre) async {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue