Clean code
This commit is contained in:
@@ -46,7 +46,6 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
|||||||
|
|
||||||
public override bool DrawConditions()
|
public override bool DrawConditions()
|
||||||
{
|
{
|
||||||
// Visible when explicitly opened; allow drawing even if discovery is disabled to show hint
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,8 +167,6 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) Fallback on alias/name (legacy compatibility)
|
|
||||||
var key = NormalizeKey(e.DisplayName ?? e.Name);
|
var key = NormalizeKey(e.DisplayName ?? e.Name);
|
||||||
if (string.IsNullOrEmpty(key)) return false;
|
if (string.IsNullOrEmpty(key)) return false;
|
||||||
foreach (var p in _pairManager.DirectPairs)
|
foreach (var p in _pairManager.DirectPairs)
|
||||||
@@ -180,7 +177,6 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// ignore
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -386,8 +386,6 @@ public class CompactUi : WindowMediatorSubscriberBase
|
|||||||
var onUmbra = _nearbyEntries?.Count(e => e.IsMatch) ?? 0;
|
var onUmbra = _nearbyEntries?.Count(e => e.IsMatch) ?? 0;
|
||||||
ImGui.TextUnformatted($"Nearby ({onUmbra})");
|
ImGui.TextUnformatted($"Nearby ({onUmbra})");
|
||||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) _nearbyOpen = !_nearbyOpen;
|
if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) _nearbyOpen = !_nearbyOpen;
|
||||||
|
|
||||||
// Header action button to open Nearby window
|
|
||||||
var btnWidth = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.UserPlus, "Nearby");
|
var btnWidth = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.UserPlus, "Nearby");
|
||||||
var headerRight = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
var headerRight = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
@@ -413,16 +411,12 @@ public class CompactUi : WindowMediatorSubscriberBase
|
|||||||
{
|
{
|
||||||
foreach (var e in nearby)
|
foreach (var e in nearby)
|
||||||
{
|
{
|
||||||
// name
|
|
||||||
var name = e.DisplayName ?? e.Name;
|
var name = e.DisplayName ?? e.Name;
|
||||||
ImGui.AlignTextToFramePadding();
|
ImGui.AlignTextToFramePadding();
|
||||||
ImGui.TextUnformatted(name);
|
ImGui.TextUnformatted(name);
|
||||||
|
|
||||||
// right side status/action
|
|
||||||
var right = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
var right = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
// detect if already paired (prefer UID if present)
|
|
||||||
bool isPaired = false;
|
bool isPaired = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -430,7 +424,6 @@ public class CompactUi : WindowMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// fall back to display name/alias matching if UID is not available
|
|
||||||
var key = (e.DisplayName ?? e.Name) ?? string.Empty;
|
var key = (e.DisplayName ?? e.Name) ?? string.Empty;
|
||||||
isPaired = _pairManager.DirectPairs.Any(p => string.Equals(p.UserData.AliasOrUID, key, StringComparison.OrdinalIgnoreCase));
|
isPaired = _pairManager.DirectPairs.Any(p => string.Equals(p.UserData.AliasOrUID, key, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
@@ -441,12 +434,10 @@ public class CompactUi : WindowMediatorSubscriberBase
|
|||||||
|
|
||||||
if (isPaired || !e.AcceptPairRequests)
|
if (isPaired || !e.AcceptPairRequests)
|
||||||
{
|
{
|
||||||
// just paint the status
|
|
||||||
ImGui.TextUnformatted(statusText);
|
ImGui.TextUnformatted(statusText);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no direct send from Compact; open Nearby window to send the invite there
|
|
||||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserPlus, "Invite", statusSize.X))
|
if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserPlus, "Invite", statusSize.X))
|
||||||
{
|
{
|
||||||
Mediator.Publish(new UiToggleMessage(typeof(AutoDetectUi)));
|
Mediator.Publish(new UiToggleMessage(typeof(AutoDetectUi)));
|
||||||
@@ -454,8 +445,6 @@ public class CompactUi : WindowMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pending Nearby requests (Accept / Dismiss)
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var inbox = _nearbyPending;
|
var inbox = _nearbyPending;
|
||||||
@@ -606,8 +595,6 @@ public class CompactUi : WindowMediatorSubscriberBase
|
|||||||
ImGui.SameLine(WindowContentWidth - textSize.X);
|
ImGui.SameLine(WindowContentWidth - textSize.X);
|
||||||
ImGui.TextUnformatted(downloadText);
|
ImGui.TextUnformatted(downloadText);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Space for three equal-width buttons laid out precisely (avoid overlap/wrap)
|
|
||||||
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
||||||
var bottomButtonWidth = (WindowContentWidth - spacing) / 2f;
|
var bottomButtonWidth = (WindowContentWidth - spacing) / 2f;
|
||||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Character Analysis", bottomButtonWidth))
|
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Character Analysis", bottomButtonWidth))
|
||||||
@@ -646,7 +633,7 @@ public class CompactUi : WindowMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
UiSharedService.AttachToolTip("Open the UmbraSync Settings");
|
UiSharedService.AttachToolTip("Open the UmbraSync Settings");
|
||||||
|
|
||||||
ImGui.SameLine(); //Important to draw the uidText consistently
|
ImGui.SameLine();
|
||||||
ImGui.SetCursorPos(originalPos);
|
ImGui.SetCursorPos(originalPos);
|
||||||
|
|
||||||
if (_apiController.ServerState is ServerState.Connected)
|
if (_apiController.ServerState is ServerState.Connected)
|
||||||
|
|||||||
@@ -44,10 +44,6 @@ public class DrawGroupPair : DrawPairBase
|
|||||||
var presenceText = entryUID + " is offline";
|
var presenceText = entryUID + " is offline";
|
||||||
|
|
||||||
ImGui.SetCursorPosY(textPosY);
|
ImGui.SetCursorPosY(textPosY);
|
||||||
|
|
||||||
// We'll draw an optional prefix icon (pause or paired-moon). If we draw one,
|
|
||||||
// we add a SameLine() before drawing the presence icon. Otherwise, we draw
|
|
||||||
// the presence icon directly at the current cursor position to avoid gaps.
|
|
||||||
bool drewPrefixIcon = false;
|
bool drewPrefixIcon = false;
|
||||||
|
|
||||||
if (_pair.IsPaused)
|
if (_pair.IsPaused)
|
||||||
@@ -65,9 +61,6 @@ public class DrawGroupPair : DrawPairBase
|
|||||||
{
|
{
|
||||||
bool individuallyPaired = _pair.UserPair != null;
|
bool individuallyPaired = _pair.UserPair != null;
|
||||||
var violet = new Vector4(0.63f, 0.25f, 1f, 1f);
|
var violet = new Vector4(0.63f, 0.25f, 1f, 1f);
|
||||||
|
|
||||||
// Show a violet moon only when individually paired AND online/visible.
|
|
||||||
// If offline or not individually paired, do not draw a moon at all.
|
|
||||||
if (individuallyPaired && (_pair.IsOnline || _pair.IsVisible))
|
if (individuallyPaired && (_pair.IsOnline || _pair.IsVisible))
|
||||||
{
|
{
|
||||||
ImGui.PushFont(UiBuilder.IconFont);
|
ImGui.PushFont(UiBuilder.IconFont);
|
||||||
@@ -77,8 +70,6 @@ public class DrawGroupPair : DrawPairBase
|
|||||||
drewPrefixIcon = true;
|
drewPrefixIcon = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Presence status icon (eye when visible, cloud-moon otherwise)
|
|
||||||
if (drewPrefixIcon)
|
if (drewPrefixIcon)
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ public class DrawUserPair : DrawPairBase
|
|||||||
|
|
||||||
protected override void DrawLeftSide(float textPosY, float originalY)
|
protected override void DrawLeftSide(float textPosY, float originalY)
|
||||||
{
|
{
|
||||||
// Primary presence indicator: moon (online = violet, offline = grey)
|
|
||||||
var online = _pair.IsOnline;
|
var online = _pair.IsOnline;
|
||||||
// Violet accent (#BA70EF)
|
|
||||||
var violet = new Vector4(0.69f, 0.27f, 0.93f, 1f);
|
var violet = new Vector4(0.69f, 0.27f, 0.93f, 1f);
|
||||||
var offlineGrey = ImGuiColors.DalamudGrey3;
|
var offlineGrey = ImGuiColors.DalamudGrey3;
|
||||||
|
|
||||||
@@ -51,9 +49,6 @@ public class DrawUserPair : DrawPairBase
|
|||||||
UiSharedService.AttachToolTip(online
|
UiSharedService.AttachToolTip(online
|
||||||
? "User is online"
|
? "User is online"
|
||||||
: "User is offline");
|
: "User is offline");
|
||||||
|
|
||||||
// Secondary pairing state badges (only if needed)
|
|
||||||
// Not mutually paired -> red ArrowUp
|
|
||||||
if (!(_pair.UserPair!.OwnPermissions.IsPaired() && _pair.UserPair!.OtherPermissions.IsPaired()))
|
if (!(_pair.UserPair!.OwnPermissions.IsPaired() && _pair.UserPair!.OtherPermissions.IsPaired()))
|
||||||
{
|
{
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
@@ -63,7 +58,6 @@ public class DrawUserPair : DrawPairBase
|
|||||||
ImGui.PopFont();
|
ImGui.PopFont();
|
||||||
UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " has not added you back");
|
UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " has not added you back");
|
||||||
}
|
}
|
||||||
// Paused (either side) -> yellow PauseCircle
|
|
||||||
else if (_pair.UserPair!.OwnPermissions.IsPaused() || _pair.UserPair!.OtherPermissions.IsPaused())
|
else if (_pair.UserPair!.OwnPermissions.IsPaused() || _pair.UserPair!.OtherPermissions.IsPaused())
|
||||||
{
|
{
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
@@ -149,8 +143,6 @@ public class DrawUserPair : DrawPairBase
|
|||||||
var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
|
var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
|
||||||
var individualAnimDisabled = (_pair.UserPair?.OwnPermissions.IsDisableAnimations() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableAnimations() ?? false);
|
var individualAnimDisabled = (_pair.UserPair?.OwnPermissions.IsDisableAnimations() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableAnimations() ?? false);
|
||||||
var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
|
var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
|
||||||
|
|
||||||
// Icon for individually applied permissions
|
|
||||||
if (individualSoundsDisabled || individualAnimDisabled || individualVFXDisabled)
|
if (individualSoundsDisabled || individualAnimDisabled || individualVFXDisabled)
|
||||||
{
|
{
|
||||||
var icon = FontAwesomeIcon.ExclamationTriangle;
|
var icon = FontAwesomeIcon.ExclamationTriangle;
|
||||||
@@ -205,8 +197,6 @@ public class DrawUserPair : DrawPairBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Icon for shared character data
|
|
||||||
if (_charaDataManager.SharedWithYouData.TryGetValue(_pair.UserData, out var sharedData))
|
if (_charaDataManager.SharedWithYouData.TryGetValue(_pair.UserData, out var sharedData))
|
||||||
{
|
{
|
||||||
var icon = FontAwesomeIcon.Running;
|
var icon = FontAwesomeIcon.Running;
|
||||||
|
|||||||
@@ -54,17 +54,12 @@ public class PairGroupsUi
|
|||||||
ImGui.SameLine(buttonPauseOffset);
|
ImGui.SameLine(buttonPauseOffset);
|
||||||
if (_uiSharedService.IconButton(pauseButton))
|
if (_uiSharedService.IconButton(pauseButton))
|
||||||
{
|
{
|
||||||
// If all of the currently visible pairs (after applying filters to the pairs)
|
|
||||||
// are paused we display a resume button to resume all currently visible (after filters)
|
|
||||||
// pairs. Otherwise, we just pause all the remaining pairs.
|
|
||||||
if (allArePaused)
|
if (allArePaused)
|
||||||
{
|
{
|
||||||
// If all are paused => resume all
|
|
||||||
ResumeAllPairs(availablePairsInThisTag);
|
ResumeAllPairs(availablePairsInThisTag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// otherwise pause all remaining
|
|
||||||
PauseRemainingPairs(availablePairsInThisTag);
|
PauseRemainingPairs(availablePairsInThisTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +115,6 @@ public class PairGroupsUi
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Avoid uncomfortably close group names
|
|
||||||
if (!_tagHandler.IsTagOpen(tag))
|
if (!_tagHandler.IsTagOpen(tag))
|
||||||
{
|
{
|
||||||
var size = ImGui.CalcTextSize("").Y + ImGui.GetStyle().FramePadding.Y * 2f;
|
var size = ImGui.CalcTextSize("").Y + ImGui.GetStyle().FramePadding.Y * 2f;
|
||||||
@@ -163,8 +157,6 @@ public class PairGroupsUi
|
|||||||
};
|
};
|
||||||
|
|
||||||
string resultFolderName = !isSpecialTag ? $"{displayedName} ({visible}/{online}/{total} Pairs)" : $"{displayedName} ({online} Pairs)";
|
string resultFolderName = !isSpecialTag ? $"{displayedName} ({visible}/{online}/{total} Pairs)" : $"{displayedName} ({online} Pairs)";
|
||||||
|
|
||||||
// FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight
|
|
||||||
var icon = _tagHandler.IsTagOpen(tag) ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
|
var icon = _tagHandler.IsTagOpen(tag) ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
|
||||||
_uiSharedService.IconText(icon);
|
_uiSharedService.IconText(icon);
|
||||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||||
|
|||||||
@@ -15,20 +15,8 @@ public class SelectGroupForPairUi
|
|||||||
private readonly UidDisplayHandler _uidDisplayHandler;
|
private readonly UidDisplayHandler _uidDisplayHandler;
|
||||||
private readonly UiSharedService _uiSharedService;
|
private readonly UiSharedService _uiSharedService;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The group UI is always open for a specific pair. This defines which pair the UI is open for.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
private Pair? _pair;
|
private Pair? _pair;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Should the panel show, yes/no
|
|
||||||
/// </summary>
|
|
||||||
private bool _show;
|
private bool _show;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// For the add category option, this stores the currently typed in tag name
|
|
||||||
/// </summary>
|
|
||||||
private string _tagNameToAdd = "";
|
private string _tagNameToAdd = "";
|
||||||
|
|
||||||
public SelectGroupForPairUi(TagHandler tagHandler, UidDisplayHandler uidDisplayHandler, UiSharedService uiSharedService)
|
public SelectGroupForPairUi(TagHandler tagHandler, UidDisplayHandler uidDisplayHandler, UiSharedService uiSharedService)
|
||||||
@@ -49,7 +37,6 @@ public class SelectGroupForPairUi
|
|||||||
|
|
||||||
var name = PairName(_pair);
|
var name = PairName(_pair);
|
||||||
var popupName = $"Choose Groups for {name}";
|
var popupName = $"Choose Groups for {name}";
|
||||||
// Is the popup supposed to show but did not open yet? Open it
|
|
||||||
if (_show)
|
if (_show)
|
||||||
{
|
{
|
||||||
ImGui.OpenPopup(popupName);
|
ImGui.OpenPopup(popupName);
|
||||||
@@ -91,10 +78,6 @@ public class SelectGroupForPairUi
|
|||||||
public void Open(Pair pair)
|
public void Open(Pair pair)
|
||||||
{
|
{
|
||||||
_pair = pair;
|
_pair = pair;
|
||||||
// Using "_show" here to de-couple the opening of the popup
|
|
||||||
// The popup name is derived from the name the user currently sees, which is
|
|
||||||
// based on the showUidForEntry dictionary.
|
|
||||||
// We'd have to derive the name here to open it popup modal here, when the Open() is called
|
|
||||||
_show = true;
|
_show = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -547,7 +547,6 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
|
|
||||||
if (ImGui.Checkbox($"Enable chat for this syncshell##{gid}", ref shellEnabled))
|
if (ImGui.Checkbox($"Enable chat for this syncshell##{gid}", ref shellEnabled))
|
||||||
{
|
{
|
||||||
// If there is an active group with the same syncshell number, pick a new one
|
|
||||||
int nextNumber = 1;
|
int nextNumber = 1;
|
||||||
bool conflict = false;
|
bool conflict = false;
|
||||||
foreach (var otherGroup in _pairManager.Groups)
|
foreach (var otherGroup in _pairManager.Groups)
|
||||||
@@ -567,17 +566,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
using var pushDisabled = ImRaii.Disabled(!shellEnabled);
|
using var pushDisabled = ImRaii.Disabled(!shellEnabled);
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(50 * ImGuiHelpers.GlobalScale);
|
ImGui.SetNextItemWidth(50 * ImGuiHelpers.GlobalScale);
|
||||||
|
|
||||||
// _uiShared.DrawCombo() remembers the selected option -- we don't want that, because the value can change
|
|
||||||
if (ImGui.BeginCombo("Syncshell number##{gid}", $"{shellNumber}"))
|
if (ImGui.BeginCombo("Syncshell number##{gid}", $"{shellNumber}"))
|
||||||
{
|
{
|
||||||
// Same hard-coded number in CommandManagerService
|
|
||||||
for (int i = 1; i <= ChatService.CommandMaxNumber; ++i)
|
for (int i = 1; i <= ChatService.CommandMaxNumber; ++i)
|
||||||
{
|
{
|
||||||
if (ImGui.Selectable($"{i}", i == shellNumber))
|
if (ImGui.Selectable($"{i}", i == shellNumber))
|
||||||
{
|
{
|
||||||
// Find an active group with the same syncshell number as selected, and swap it
|
|
||||||
// This logic can leave duplicate IDs present in the config but its not critical
|
|
||||||
foreach (var otherGroup in _pairManager.Groups)
|
foreach (var otherGroup in _pairManager.Groups)
|
||||||
{
|
{
|
||||||
if (gid.Equals(otherGroup.Key.GID, StringComparison.Ordinal)) continue;
|
if (gid.Equals(otherGroup.Key.GID, StringComparison.Ordinal)) continue;
|
||||||
@@ -1665,8 +1660,6 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
string selectedKeyName = string.Empty;
|
string selectedKeyName = string.Empty;
|
||||||
if (selectedServer.SecretKeys.TryGetValue(item.SecretKeyIdx, out var selectedKey))
|
if (selectedServer.SecretKeys.TryGetValue(item.SecretKeyIdx, out var selectedKey))
|
||||||
selectedKeyName = selectedKey.FriendlyName;
|
selectedKeyName = selectedKey.FriendlyName;
|
||||||
|
|
||||||
// _uiShared.DrawCombo() remembers the selected option -- we don't want that, because the value can change
|
|
||||||
if (ImGui.BeginCombo($"##{item.CharacterName}{i}", selectedKeyName))
|
if (ImGui.BeginCombo($"##{item.CharacterName}{i}", selectedKeyName))
|
||||||
{
|
{
|
||||||
foreach (var key in selectedServer.SecretKeys)
|
foreach (var key in selectedServer.SecretKeys)
|
||||||
@@ -1945,7 +1938,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
ImGui.BeginDisabled(_registrationInProgress);
|
ImGui.BeginDisabled(_registrationInProgress);
|
||||||
DrawServerConfiguration();
|
DrawServerConfiguration();
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
ImGui.EndDisabled(); // _registrationInProgress
|
ImGui.EndDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.BeginTabItem("Chat"))
|
if (ImGui.BeginTabItem("Chat"))
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ public class DiscoveryApiClient
|
|||||||
private readonly DiscoveryConfigProvider _configProvider;
|
private readonly DiscoveryConfigProvider _configProvider;
|
||||||
private readonly HttpClient _httpClient = new();
|
private readonly HttpClient _httpClient = new();
|
||||||
private static readonly JsonSerializerOptions JsonOpt = new() { PropertyNameCaseInsensitive = true };
|
private static readonly JsonSerializerOptions JsonOpt = new() { PropertyNameCaseInsensitive = true };
|
||||||
// private readonly ISaltProvider _saltProvider; // For future use if needed
|
|
||||||
|
|
||||||
public DiscoveryApiClient(ILogger<DiscoveryApiClient> logger, TokenProvider tokenProvider, DiscoveryConfigProvider configProvider)
|
public DiscoveryApiClient(ILogger<DiscoveryApiClient> logger, TokenProvider tokenProvider, DiscoveryConfigProvider configProvider)
|
||||||
{
|
{
|
||||||
@@ -41,7 +40,6 @@ public class DiscoveryApiClient
|
|||||||
var resp = await _httpClient.SendAsync(req, ct).ConfigureAwait(false);
|
var resp = await _httpClient.SendAsync(req, ct).ConfigureAwait(false);
|
||||||
if (resp.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
if (resp.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||||
{
|
{
|
||||||
// Retry once with a fresh token
|
|
||||||
var token2 = await _tokenProvider.GetOrUpdateToken(ct).ConfigureAwait(false);
|
var token2 = await _tokenProvider.GetOrUpdateToken(ct).ConfigureAwait(false);
|
||||||
if (string.IsNullOrEmpty(token2)) return [];
|
if (string.IsNullOrEmpty(token2)) return [];
|
||||||
using var req2 = new HttpRequestMessage(HttpMethod.Post, endpoint);
|
using var req2 = new HttpRequestMessage(HttpMethod.Post, endpoint);
|
||||||
@@ -178,7 +176,6 @@ public class DiscoveryApiClient
|
|||||||
if (string.IsNullOrEmpty(jwt)) return;
|
if (string.IsNullOrEmpty(jwt)) return;
|
||||||
using var req = new HttpRequestMessage(HttpMethod.Post, endpoint);
|
using var req = new HttpRequestMessage(HttpMethod.Post, endpoint);
|
||||||
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", jwt);
|
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", jwt);
|
||||||
// no body required
|
|
||||||
var resp = await _httpClient.SendAsync(req, ct).ConfigureAwait(false);
|
var resp = await _httpClient.SendAsync(req, ct).ConfigureAwait(false);
|
||||||
if (resp.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
if (resp.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user