postit: persist settings save and apply ApiUrl changes without restart #51

Merged
notazof merged 25 commits from feat/estimate into main 2026-09-06 21:05:58 +01:00
2 changed files with 27 additions and 1 deletions
Showing only changes of commit 82c479434e - Show all commits

postit: debounce rdv reverse geocoding

Paul Schneider 2026-09-06 17:19:21 +01:00
Signed by: notazof
GPG key ID: 1DD5D838E5343B06

View file

@ -133,6 +133,22 @@ public partial class RdvViewModel : BillingCommandPageViewModel
this.SetInfoStatus("Position sélectionnée sur la carte."); this.SetInfoStatus("Position sélectionnée sur la carte.");
} }
public void NotifyReverseGeocodingStarted()
{
this.SetInfoStatus(string.IsNullOrWhiteSpace(Address)
? "Recherche de l'adresse depuis la carte..."
: "Recherche d'une adresse suggérée..."
);
}
public void NotifyReverseGeocodingUnavailable()
{
if (HasSuggestedAddress || !string.IsNullOrWhiteSpace(Address))
return;
this.SetInfoStatus("Position sélectionnée sur la carte. Complétez l'adresse puis envoyez la commande.");
}
public void ApplyResolvedAddress(string address) public void ApplyResolvedAddress(string address)
{ {
if (string.IsNullOrWhiteSpace(address)) if (string.IsNullOrWhiteSpace(address))

View file

@ -22,6 +22,7 @@ public partial class RdvPage : ContentPage
private const double DefaultLongitude = 2.3522; private const double DefaultLongitude = 2.3522;
private const int DefaultZoomLevel = 4; private const int DefaultZoomLevel = 4;
private const int SelectedZoomLevel = 13; private const int SelectedZoomLevel = 13;
private static readonly TimeSpan ReverseGeocodingDebounce = TimeSpan.FromMilliseconds(350);
private MapControl? _locationMap; private MapControl? _locationMap;
private MemoryLayer? _selectionLayer; private MemoryLayer? _selectionLayer;
@ -182,15 +183,24 @@ public partial class RdvPage : ContentPage
_reverseGeocodeCts?.Cancel(); _reverseGeocodeCts?.Cancel();
_reverseGeocodeCts?.Dispose(); _reverseGeocodeCts?.Dispose();
_reverseGeocodeCts = new CancellationTokenSource(); _reverseGeocodeCts = new CancellationTokenSource();
var cancellationToken = _reverseGeocodeCts.Token;
try try
{ {
vm.NotifyReverseGeocodingStarted();
await Task.Delay(ReverseGeocodingDebounce, cancellationToken).ConfigureAwait(true);
var resolved = await _reverseGeocodingService var resolved = await _reverseGeocodingService
.TryResolveAddressAsync(latitude, longitude, _reverseGeocodeCts.Token) .TryResolveAddressAsync(latitude, longitude, cancellationToken)
.ConfigureAwait(true); .ConfigureAwait(true);
if (!string.IsNullOrWhiteSpace(resolved)) if (!string.IsNullOrWhiteSpace(resolved))
{
vm.ApplyResolvedAddress(resolved); vm.ApplyResolvedAddress(resolved);
return;
}
vm.NotifyReverseGeocodingUnavailable();
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {