auto dismiss notifs if no updates
This commit is contained in:
@@ -24,6 +24,8 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
private readonly ConcurrentDictionary<GameObjectHandler, bool> _uploadingPlayers = new();
|
||||
private bool _notificationDismissed = true;
|
||||
private int _lastDownloadStateHash = 0;
|
||||
private DateTime _lastNotificationUpdate = DateTime.MinValue;
|
||||
private const int NotificationAutoCloseSeconds = 15;
|
||||
|
||||
public DownloadUi(ILogger<DownloadUi> logger, DalamudUtilService dalamudUtilService, LightlessConfigService configService,
|
||||
PairProcessingLimiter pairProcessingLimiter, FileUploadManager fileTransferManager, LightlessMediator mediator, UiSharedService uiShared,
|
||||
@@ -147,6 +149,20 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
_notificationDismissed = true;
|
||||
_lastDownloadStateHash = 0;
|
||||
}
|
||||
|
||||
// Auto-dismiss notification if no updates for 15 seconds
|
||||
if (!_notificationDismissed && _lastNotificationUpdate != DateTime.MinValue)
|
||||
{
|
||||
var timeSinceLastUpdate = (DateTime.UtcNow - _lastNotificationUpdate).TotalSeconds;
|
||||
if (timeSinceLastUpdate > NotificationAutoCloseSeconds)
|
||||
{
|
||||
_logger.LogDebug("Auto-dismissing download notification after {Seconds}s of inactivity", timeSinceLastUpdate);
|
||||
Mediator.Publish(new LightlessNotificationDismissMessage("pair_download_progress"));
|
||||
_notificationDismissed = true;
|
||||
_lastDownloadStateHash = 0;
|
||||
_lastNotificationUpdate = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -363,11 +379,11 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
if (currentHash != _lastDownloadStateHash)
|
||||
{
|
||||
_lastDownloadStateHash = currentHash;
|
||||
_lastNotificationUpdate = DateTime.UtcNow;
|
||||
if (downloadStatus.Count > 0 || queueWaiting > 0)
|
||||
{
|
||||
Mediator.Publish(new PairDownloadStatusMessage(downloadStatus, queueWaiting));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user