< Summary

Class:DCLPlugins.RealmPlugin.RealmBlockerModifier
Assembly:DCL.Plugins.RealmsPlugin
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/RealmsPlugin/RealmBlockerModifier.cs
Covered lines:10
Uncovered lines:1
Coverable lines:11
Total lines:39
Line coverage:90.9% (10 of 11)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RealmBlockerModifier(...)0%110100%
Dispose()0%110100%
OnEnteredRealm(...)0%5.25080%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/RealmsPlugin/RealmBlockerModifier.cs

#LineLine coverage
 1using DCL;
 2using static Decentraland.Bff.AboutResponse.Types;
 3
 4namespace DCLPlugins.RealmPlugin
 5{
 6    /// <summary>
 7    /// Toggles the state of the green blockers depending if the realm just entered is a world.
 8    /// Also, it has a feature flag so we have the possibility to turn them off entirely.
 9    /// </summary>
 10    public class RealmBlockerModifier : IRealmModifier
 11    {
 12        private const int WORLD_BLOCKER_LIMIT = 2;
 13        private const string ENABLE_GREEN_BLOCKERS_WORLDS_FF = "realms_blockers_in_worlds";
 14
 15        private readonly BaseVariable<bool> worldBlockersEnabled;
 16        private readonly BaseVariable<int> worldBlockersLimit;
 17
 818        public RealmBlockerModifier(DataStore_WorldBlockers dataStoreWorldBlockers)
 19        {
 820            worldBlockersEnabled = dataStoreWorldBlockers.worldBlockerEnabled;
 821            worldBlockersLimit = dataStoreWorldBlockers.worldBlockerLimit;
 822        }
 23
 224        public void Dispose() { }
 25
 26        public void OnEnteredRealm(bool isWorld, AboutConfiguration realmConfiguration)
 27        {
 628            bool shouldGreenBlockersBeActive = !isWorld || HasContentServers(realmConfiguration.CityLoaderContentServer)
 29
 30            bool HasContentServers(string cityLoaderContentServers) =>
 331                !string.IsNullOrEmpty(cityLoaderContentServers);
 32
 633            if (DataStore.i.featureFlags.flags.Get().IsFeatureEnabled(ENABLE_GREEN_BLOCKERS_WORLDS_FF))
 034                worldBlockersLimit.Set(shouldGreenBlockersBeActive ? 0 : WORLD_BLOCKER_LIMIT);
 35            else
 636                worldBlockersEnabled.Set(shouldGreenBlockersBeActive);
 637        }
 38    }
 39}