Added another try on fetching download status
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Game.ClientState.Statuses;
|
||||
using Dalamud.Interface.Colors;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
using LightlessSync.LightlessConfiguration.Models;
|
||||
@@ -167,22 +168,30 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
List<KeyValuePair<GameObjectHandler, Dictionary<string, FileDownloadStatus>>> transfers;
|
||||
try
|
||||
{
|
||||
transfers = _currentDownloads.ToList();
|
||||
transfers = _currentDownloads?.ToList() ?? [];
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
foreach (var transfer in transfers)
|
||||
{
|
||||
var transferKey = transfer.Key;
|
||||
|
||||
// Skip if no valid game object
|
||||
if (transferKey.GetGameObject() == null)
|
||||
if (transferKey is null)
|
||||
continue;
|
||||
|
||||
var statusDict = transfer.Value;
|
||||
if (statusDict is null)
|
||||
continue;
|
||||
|
||||
var gameObj = transferKey.GetGameObject();
|
||||
if (gameObj is null)
|
||||
{
|
||||
_smoothed.Remove(transferKey);
|
||||
continue;
|
||||
}
|
||||
|
||||
var rawPos = _dalamudUtilService.WorldToScreen(transferKey.GetGameObject());
|
||||
|
||||
// If RawPos is zero, remove it from smoothed dictionary
|
||||
@@ -207,25 +216,29 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
var dlProg = 0;
|
||||
var dlDecomp = 0;
|
||||
|
||||
foreach (var entry in transfer.Value)
|
||||
try
|
||||
{
|
||||
var fileStatus = entry.Value;
|
||||
switch (fileStatus.DownloadStatus)
|
||||
foreach (var entry in statusDict)
|
||||
{
|
||||
case DownloadStatus.WaitingForSlot:
|
||||
dlSlot++;
|
||||
break;
|
||||
case DownloadStatus.WaitingForQueue:
|
||||
dlQueue++;
|
||||
break;
|
||||
case DownloadStatus.Downloading:
|
||||
dlProg++;
|
||||
break;
|
||||
case DownloadStatus.Decompressing:
|
||||
dlDecomp++;
|
||||
break;
|
||||
var fileStatus = entry.Value;
|
||||
if (fileStatus is null) continue;
|
||||
|
||||
totalBytes += fileStatus.TotalBytes;
|
||||
transferredBytes += fileStatus.TransferredBytes;
|
||||
|
||||
switch (fileStatus.DownloadStatus)
|
||||
{
|
||||
case DownloadStatus.WaitingForSlot: dlSlot++; break;
|
||||
case DownloadStatus.WaitingForQueue: dlQueue++; break;
|
||||
case DownloadStatus.Downloading: dlProg++; break;
|
||||
case DownloadStatus.Decompressing: dlDecomp++; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string statusText;
|
||||
if (dlProg > 0)
|
||||
|
||||
Reference in New Issue
Block a user