UI Update & Fix Nearby
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -4,6 +4,7 @@ using Lumina.Data.Files;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.UI;
|
||||
@@ -29,8 +30,9 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
private const long NotificationTriangleThreshold = 150_000;
|
||||
private bool _sizeWarningShown;
|
||||
private bool _triangleWarningShown;
|
||||
private readonly PlayerPerformanceConfigService _playerPerformanceConfigService;
|
||||
|
||||
public CharacterAnalyzer(ILogger<CharacterAnalyzer> logger, MareMediator mediator, FileCacheManager fileCacheManager, XivDataAnalyzer modelAnalyzer)
|
||||
public CharacterAnalyzer(ILogger<CharacterAnalyzer> logger, MareMediator mediator, FileCacheManager fileCacheManager, XivDataAnalyzer modelAnalyzer, PlayerPerformanceConfigService playerPerformanceConfigService)
|
||||
: base(logger, mediator)
|
||||
{
|
||||
Mediator.Subscribe<CharacterDataCreatedMessage>(this, (msg) =>
|
||||
@@ -41,6 +43,7 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
});
|
||||
_fileCacheManager = fileCacheManager;
|
||||
_xivDataAnalyzer = modelAnalyzer;
|
||||
_playerPerformanceConfigService = playerPerformanceConfigService;
|
||||
}
|
||||
|
||||
public int CurrentFile { get; internal set; }
|
||||
@@ -313,6 +316,12 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_playerPerformanceConfigService.Current.ShowSelfAnalysisWarnings)
|
||||
{
|
||||
ResetThresholdFlagsIfNeeded(summary);
|
||||
return;
|
||||
}
|
||||
|
||||
bool sizeExceeded = summary.TotalCompressedSize >= NotificationSizeThreshold;
|
||||
bool trianglesExceeded = summary.TotalTriangles >= NotificationTriangleThreshold;
|
||||
List<string> exceededReasons = new();
|
||||
|
||||
Reference in New Issue
Block a user