syncshell list cleanup

This commit is contained in:
choco
2026-01-07 01:08:28 +01:00
parent 05f7d256d7
commit 42d6a19db1

View File

@@ -497,7 +497,7 @@ public class LightFinderUI : WindowMediatorSubscriberBase
var cardData = new List<(GroupJoinDto Shell, string BroadcasterName, bool IsOwnBroadcast)>();
foreach (var shell in _nearbySyncshells)
foreach (var shell in _nearbySyncshells.ToArray())
{
if (shell?.Group == null || string.IsNullOrEmpty(shell.Group.GID))
continue;
@@ -1566,11 +1566,20 @@ public class LightFinderUI : WindowMediatorSubscriberBase
if (previousGid != null)
{
var newIndex = _nearbySyncshells.FindIndex(s => string.Equals(s.Group.GID, previousGid, StringComparison.Ordinal));
if (newIndex >= 0)
try
{
_selectedNearbyIndex = newIndex;
return;
var nearbySyncshellsSnapshot = _nearbySyncshells.ToArray();
var newIndex = Array.FindIndex(nearbySyncshellsSnapshot,
s => string.Equals(s.Group.GID, previousGid, StringComparison.Ordinal));
if (newIndex >= 0)
{
_selectedNearbyIndex = newIndex;
return;
}
}
catch
{
ClearSelection();
}
}
@@ -1612,9 +1621,18 @@ public class LightFinderUI : WindowMediatorSubscriberBase
private string? GetSelectedGid()
{
if (_selectedNearbyIndex < 0 || _selectedNearbyIndex >= _nearbySyncshells.Count)
try
{
var index = _selectedNearbyIndex;
var list = _nearbySyncshells.ToArray();
if (index < 0 || index >= list.Length)
return null;
return list[index].Group.GID;
}
catch
{
return null;
return _nearbySyncshells[_selectedNearbyIndex].Group.GID;
}
}
#endregion