use nullorempty

This commit is contained in:
Stanley Dimant
2024-12-17 17:02:57 +01:00
parent dbf4a90df2
commit 4650893599
4 changed files with 7 additions and 7 deletions

View File

@@ -284,7 +284,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
}
else
{
if (selectedServer.OAuthToken == null)
if (string.IsNullOrEmpty(selectedServer.OAuthToken))
{
UiSharedService.TextWrapped("Press the button below to verify the server has OAuth2 capabilities. Afterwards, authenticate using Discord in the Browser window.");
_uiShared.DrawOAuth(selectedServer);

View File

@@ -1447,7 +1447,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
" Make sure to enter the character names correctly or use the 'Add current character' button at the bottom.", ImGuiColors.DalamudYellow);
int i = 0;
_uiShared.DrawUpdateOAuthUIDsButton(selectedServer);
if (selectedServer.UseOAuth2 && selectedServer.OAuthToken != null)
if (selectedServer.UseOAuth2 && !string.IsNullOrEmpty(selectedServer.OAuthToken))
{
bool hasSetSecretKeysButNoUid = selectedServer.Authentications.Exists(u => u.SecretKeyIdx != -1 && string.IsNullOrEmpty(u.UID));
if (hasSetSecretKeysButNoUid)

View File

@@ -863,17 +863,17 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
public void DrawUpdateOAuthUIDsButton(ServerStorage selectedServer)
{
using (ImRaii.Disabled(selectedServer.OAuthToken == null))
using (ImRaii.Disabled(string.IsNullOrEmpty(selectedServer.OAuthToken)))
{
if ((_discordOAuthUIDs == null || _discordOAuthUIDs.IsCompleted)
&& IconTextButton(FontAwesomeIcon.ArrowsSpin, "Update UIDs from Service")
&& selectedServer.OAuthToken != null)
&& !string.IsNullOrEmpty(selectedServer.OAuthToken))
{
_discordOAuthUIDs = _serverConfigurationManager.GetUIDsWithDiscordToken(selectedServer.ServerUri, selectedServer.OAuthToken);
}
}
DateTime tokenExpiry = DateTime.MinValue;
if (selectedServer.OAuthToken != null && !_oauthTokenExpiry.TryGetValue(selectedServer.OAuthToken, out tokenExpiry))
if (!string.IsNullOrEmpty(selectedServer.OAuthToken) && !_oauthTokenExpiry.TryGetValue(selectedServer.OAuthToken, out tokenExpiry))
{
try
{
@@ -889,7 +889,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
tokenExpiry = DateTime.MinValue;
}
}
if (selectedServer.OAuthToken == null || tokenExpiry < DateTime.UtcNow)
if (string.IsNullOrEmpty(selectedServer.OAuthToken) || tokenExpiry < DateTime.UtcNow)
{
ColorTextWrapped("You have no OAuth token or the OAuth token is expired. Please use the Service Settings to (re)link your OAuth account.", ImGuiColors.DalamudRed);
}