Skip to content

Commit c4e0c9e

Browse files
committed
Refactor position handling to record positions even when there are not entries present
Moved accuracy check earlier in the method to ensure only valid positions are sent. This improves code clarity and avoids unnecessary operations for invalid positions.
1 parent f686a11 commit c4e0c9e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Streckenbuch.Client/Services/FahrenPositionService.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ public async Task UpdatePosition(GeolocationPosition newPosition)
5353
try
5454
{
5555
await _semaphoreSlim.WaitAsync();
56-
56+
57+
if (newPosition.Coords.Accuracy <= 100)
58+
{
59+
await _sender.Send(new PositionRecievedEvent()
60+
{
61+
Position = newPosition
62+
});
63+
}
64+
5765
if (!HasValidEntries())
5866
{
5967
_semaphoreSlim.Release();
@@ -70,14 +78,6 @@ public async Task UpdatePosition(GeolocationPosition newPosition)
7078
return;
7179
}
7280

73-
if (newPosition.Coords.Accuracy <= 100)
74-
{
75-
await _sender.Send(new PositionRecievedEvent()
76-
{
77-
Position = newPosition
78-
});
79-
}
80-
8181
if (IsWithinAccuracyThreshold(newPosition))
8282
{
8383
_semaphoreSlim.Release();

0 commit comments

Comments
 (0)