UI Update & Fix Nearby

This commit is contained in:
2025-11-01 01:09:06 +01:00
parent 84586cac3d
commit 513845b811
12 changed files with 188 additions and 72 deletions

View File

@@ -8,6 +8,7 @@ using MareSynchronos.WebAPI.AutoDetect;
using Dalamud.Plugin.Services;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using MareSynchronos.Utils;
namespace MareSynchronos.Services.AutoDetect;
@@ -35,6 +36,8 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
private bool _lastAutoDetectState;
private DateTime _lastHeartbeat = DateTime.MinValue;
private static readonly TimeSpan HeartbeatInterval = TimeSpan.FromSeconds(75);
private readonly object _entriesLock = new();
private List<NearbyEntry> _lastEntries = [];
public NearbyDiscoveryService(ILogger<NearbyDiscoveryService> logger, MareMediator mediator,
MareConfigService config, DiscoveryConfigProvider configProvider, DalamudUtilService dalamudUtilService,
@@ -134,6 +137,22 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
return Task.CompletedTask;
}
public List<NearbyEntry> SnapshotEntries()
{
lock (_entriesLock)
{
return _lastEntries.ToList();
}
}
private void UpdateSnapshot(List<NearbyEntry> entries)
{
lock (_entriesLock)
{
_lastEntries = entries.ToList();
}
}
private static void CancelAndDispose(ref CancellationTokenSource? cts)
{
if (cts == null) return;
@@ -443,6 +462,7 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
_logger.LogDebug("Nearby: well-known not available or disabled; running in local-only mode");
}
}
UpdateSnapshot(entries);
_mediator.Publish(new DiscoveryListUpdated(entries));
var delayMs = Math.Max(1000, _configProvider.MinQueryIntervalMs);