ui(client): optimize installation key caching & show invalid key hint
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using Unleash;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Unleash;
|
||||
using Unleash.ClientFactory;
|
||||
|
||||
namespace ModpackUpdater.Manager;
|
||||
|
||||
public class ModpackFeatures(ModpackConfig modpackConfig)
|
||||
{
|
||||
private IUnleash api;
|
||||
private IUnleash? api;
|
||||
private UnleashContext context;
|
||||
private UnleashSettings settings;
|
||||
|
||||
@@ -26,20 +27,28 @@ public class ModpackFeatures(ModpackConfig modpackConfig)
|
||||
return CheckFeature(feature, context);
|
||||
}
|
||||
|
||||
public bool IsInvalid()
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(modpackConfig.UnleashApiUrl) || string.IsNullOrWhiteSpace(modpackConfig.UnleashInstanceId);
|
||||
}
|
||||
|
||||
[MemberNotNullWhen(true, nameof(api))]
|
||||
private bool InitializeApi()
|
||||
{
|
||||
if (api == null && !string.IsNullOrWhiteSpace(modpackConfig.UnleashApiUrl) && !string.IsNullOrWhiteSpace(modpackConfig.UnleashInstanceId))
|
||||
if (api != null
|
||||
|| string.IsNullOrWhiteSpace(modpackConfig.UnleashApiUrl)
|
||||
|| string.IsNullOrWhiteSpace(modpackConfig.UnleashInstanceId))
|
||||
return api != null;
|
||||
|
||||
settings = new UnleashSettings
|
||||
{
|
||||
settings = new UnleashSettings
|
||||
{
|
||||
AppName = "Modpack Updater",
|
||||
UnleashApi = new Uri(modpackConfig.UnleashApiUrl),
|
||||
FetchTogglesInterval = TimeSpan.FromSeconds(60 * 5),
|
||||
InstanceTag = modpackConfig.UnleashInstanceId,
|
||||
};
|
||||
AppName = "Modpack Updater",
|
||||
UnleashApi = new Uri(modpackConfig.UnleashApiUrl),
|
||||
FetchTogglesInterval = TimeSpan.FromSeconds(0),
|
||||
InstanceTag = modpackConfig.UnleashInstanceId,
|
||||
};
|
||||
|
||||
api = new UnleashClientFactory().CreateClient(settings, synchronousInitialization: true);
|
||||
}
|
||||
api = new UnleashClientFactory().CreateClient(settings, synchronousInitialization: true);
|
||||
|
||||
return api != null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user