Added refetch of syncshells after comfirmation.
This commit is contained in:
@@ -103,6 +103,14 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
||||
return;
|
||||
}
|
||||
|
||||
DrawSyncshellTable();
|
||||
|
||||
if (_joinDto != null && _joinInfo != null && _joinInfo.Success)
|
||||
DrawConfirmation();
|
||||
}
|
||||
|
||||
private void DrawSyncshellTable()
|
||||
{
|
||||
if (ImGui.BeginTable("##NearbySyncshellsTable", 3, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg))
|
||||
{
|
||||
ImGui.TableSetupColumn("Syncshell", ImGuiTableColumnFlags.WidthStretch);
|
||||
@@ -122,18 +130,18 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
||||
var broadcasterName = "Unknown";
|
||||
var broadcast = _broadcastScannerService.GetActiveSyncshellBroadcasts()
|
||||
.FirstOrDefault(b => string.Equals(b.GID, shell.Group.GID, StringComparison.Ordinal));
|
||||
|
||||
|
||||
if (broadcast != null)
|
||||
{
|
||||
var playerInfo = _dalamudUtilService.FindPlayerByNameHash(broadcast.HashedCID);
|
||||
if (!string.IsNullOrEmpty(playerInfo.Name))
|
||||
var (Name, Address) = _dalamudUtilService.FindPlayerByNameHash(broadcast.HashedCID);
|
||||
if (!string.IsNullOrEmpty(Name))
|
||||
{
|
||||
var worldName = _dalamudUtilService.GetWorldNameFromPlayerAddress(playerInfo.Address);
|
||||
broadcasterName = !string.IsNullOrEmpty(worldName) ? $"{playerInfo.Name} ({worldName})" : playerInfo.Name;
|
||||
var worldName = _dalamudUtilService.GetWorldNameFromPlayerAddress(Address);
|
||||
broadcasterName = !string.IsNullOrEmpty(worldName) ? $"{Name} ({worldName})" : Name;
|
||||
}
|
||||
}
|
||||
ImGui.TextUnformatted(broadcasterName);
|
||||
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
|
||||
var label = $"Join##{shell.Group.GID}";
|
||||
@@ -179,7 +187,6 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
using (ImRaii.Disabled())
|
||||
{
|
||||
ImGui.Button(label);
|
||||
@@ -191,9 +198,6 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
if (_joinDto != null && _joinInfo != null && _joinInfo.Success)
|
||||
DrawConfirmation();
|
||||
}
|
||||
|
||||
private void DrawConfirmation()
|
||||
@@ -222,6 +226,7 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
||||
_ = _apiController.GroupJoinFinalize(new GroupJoinDto(_joinDto.Group, _joinDto.Password, finalPermissions));
|
||||
_joinDto = null;
|
||||
_joinInfo = null;
|
||||
_ = RefreshSyncshellsAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,7 +260,7 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
||||
private async Task RefreshSyncshellsAsync()
|
||||
{
|
||||
var syncshellBroadcasts = _broadcastScannerService.GetActiveSyncshellBroadcasts();
|
||||
_currentSyncshells = _pairManager.GroupPairs.Select(g => g.Key).ToList();
|
||||
_currentSyncshells = [.. _pairManager.GroupPairs.Select(g => g.Key)];
|
||||
|
||||
if (syncshellBroadcasts.Count == 0)
|
||||
{
|
||||
@@ -263,7 +268,7 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
||||
return;
|
||||
}
|
||||
|
||||
List<GroupJoinDto> updatedList = [];
|
||||
List<GroupJoinDto>? updatedList = [];
|
||||
try
|
||||
{
|
||||
var groups = await _apiController.GetBroadcastedGroups(syncshellBroadcasts).ConfigureAwait(false);
|
||||
@@ -276,23 +281,27 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
||||
}
|
||||
|
||||
var currentGids = _nearbySyncshells.Select(s => s.Group.GID).ToHashSet(StringComparer.Ordinal);
|
||||
var newGids = updatedList.Select(s => s.Group.GID).ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
if (currentGids.SetEquals(newGids))
|
||||
return;
|
||||
|
||||
var previousGid = GetSelectedGid();
|
||||
|
||||
_nearbySyncshells.Clear();
|
||||
_nearbySyncshells.AddRange(updatedList);
|
||||
|
||||
if (previousGid != null)
|
||||
if (updatedList != null)
|
||||
{
|
||||
var newIndex = _nearbySyncshells.FindIndex(s => string.Equals(s.Group.GID, previousGid, StringComparison.Ordinal));
|
||||
if (newIndex >= 0)
|
||||
{
|
||||
_selectedNearbyIndex = newIndex;
|
||||
var newGids = updatedList.Select(s => s.Group.GID).ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
if (currentGids.SetEquals(newGids))
|
||||
return;
|
||||
|
||||
var previousGid = GetSelectedGid();
|
||||
|
||||
_nearbySyncshells.Clear();
|
||||
_nearbySyncshells.AddRange(updatedList);
|
||||
|
||||
if (previousGid != null)
|
||||
{
|
||||
var newIndex = _nearbySyncshells.FindIndex(s => string.Equals(s.Group.GID, previousGid, StringComparison.Ordinal));
|
||||
if (newIndex >= 0)
|
||||
{
|
||||
_selectedNearbyIndex = newIndex;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user