fix mods not applying race condition, fix service settings empty maybe

This commit is contained in:
rootdarkarchon
2023-05-16 17:34:52 +02:00
parent a272f7819f
commit 4ef2054995
3 changed files with 50 additions and 28 deletions

View File

@@ -23,6 +23,7 @@ public class ServerConfigurationManager
_serverTagConfig = serverTagConfig;
_notesConfig = notesConfig;
_dalamudUtil = dalamudUtil;
EnsureMainExists();
}
public string CurrentApiUrl => CurrentServer.ServerUri;
@@ -96,11 +97,7 @@ public class ServerConfigurationManager
catch
{
_configService.Current.CurrentServer = 0;
if (!string.Equals(_configService.Current.ServerStorage[0].ServerUri, ApiController.MainServer, StringComparison.OrdinalIgnoreCase))
{
_configService.Current.ServerStorage.Insert(0, new ServerStorage() { ServerUri = ApiController.MainServiceUri, ServerName = ApiController.MainServer });
}
Save();
EnsureMainExists();
return CurrentServer!;
}
}
@@ -341,6 +338,15 @@ public class ServerConfigurationManager
return _serverTagConfig.Current.ServerTagStorage[CurrentApiUrl];
}
private void EnsureMainExists()
{
if (_configService.Current.ServerStorage.Count == 0 || !string.Equals(_configService.Current.ServerStorage[0].ServerUri, ApiController.MainServiceUri, StringComparison.OrdinalIgnoreCase))
{
_configService.Current.ServerStorage.Insert(0, new ServerStorage() { ServerUri = ApiController.MainServiceUri, ServerName = ApiController.MainServer });
}
Save();
}
private void TryCreateCurrentNotesStorage()
{
if (!_notesConfig.Current.ServerNotes.ContainsKey(CurrentApiUrl))