From 4650893599ceca69876d2f22fbd59910351236fd Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Tue, 17 Dec 2024 17:02:57 +0100 Subject: [PATCH] use nullorempty --- .../ServerConfiguration/ServerConfigurationManager.cs | 2 +- MareSynchronos/UI/IntroUI.cs | 2 +- MareSynchronos/UI/SettingsUi.cs | 2 +- MareSynchronos/UI/UISharedService.cs | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MareSynchronos/Services/ServerConfiguration/ServerConfigurationManager.cs b/MareSynchronos/Services/ServerConfiguration/ServerConfigurationManager.cs index e467bb0..615e200 100644 --- a/MareSynchronos/Services/ServerConfiguration/ServerConfigurationManager.cs +++ b/MareSynchronos/Services/ServerConfiguration/ServerConfigurationManager.cs @@ -196,7 +196,7 @@ public class ServerConfigurationManager public string GetDiscordUserFromToken(ServerStorage server) { JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler(); - if (server.OAuthToken == null) return string.Empty; + if (string.IsNullOrEmpty(server.OAuthToken)) return string.Empty; try { var token = handler.ReadJwtToken(server.OAuthToken); diff --git a/MareSynchronos/UI/IntroUI.cs b/MareSynchronos/UI/IntroUI.cs index b0be74f..6ff01a6 100644 --- a/MareSynchronos/UI/IntroUI.cs +++ b/MareSynchronos/UI/IntroUI.cs @@ -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); diff --git a/MareSynchronos/UI/SettingsUi.cs b/MareSynchronos/UI/SettingsUi.cs index 1321086..4ed19d7 100644 --- a/MareSynchronos/UI/SettingsUi.cs +++ b/MareSynchronos/UI/SettingsUi.cs @@ -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) diff --git a/MareSynchronos/UI/UISharedService.cs b/MareSynchronos/UI/UISharedService.cs index 4e6230b..8ec139a 100644 --- a/MareSynchronos/UI/UISharedService.cs +++ b/MareSynchronos/UI/UISharedService.cs @@ -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); }