< Summary

Class:DCL.MyAccount.CollapsableSortedBlockedEntryList
Assembly:MyAccountHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/MyAccountHUD/CollapsableSortedBlockedEntryList.cs
Covered lines:0
Uncovered lines:26
Coverable lines:26
Total lines:67
Line coverage:0% (0 of 26)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:8
Method coverage:0% (0 of 8)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CollapsableSortedBlockedEntryList()0%2100%
Clear()0%2100%
Remove(...)0%6200%
Set(...)0%6200%
CreateEntry(...)0%2100%
GetEntryPool()0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/MyAccountHUD/CollapsableSortedBlockedEntryList.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UIComponents.CollapsableSortedList;
 4using UnityEngine;
 5
 6namespace DCL.MyAccount
 7{
 8    public class CollapsableSortedBlockedEntryList : CollapsableSortedListComponentView<string, BlockedUserEntry>
 9    {
 10        private const string POOL_NAME_PREFIX = "BlockedEntryPool_";
 11        [SerializeField] private BlockedUserEntry entryPrefab;
 12
 13        private Pool entryPool;
 014        private readonly Dictionary<string, PoolableObject> pooleableEntries = new Dictionary<string, PoolableObject>();
 15
 016        public Action<string> OnUnblockUser { get; set; }
 17
 18        public void Clear()
 19        {
 020            base.Clear();
 021            pooleableEntries.Clear();
 022        }
 23
 24        public override BlockedUserEntry Remove(string key)
 25        {
 026            if (pooleableEntries.ContainsKey(key))
 027                pooleableEntries[key].Release();
 028            pooleableEntries.Remove(key);
 29
 030            return base.Remove(key);
 31        }
 32
 33        public void Set(string userId, BlockedUserEntryModel entryModel)
 34        {
 035            if (!Contains(entryModel.userId))
 036                CreateEntry(userId);
 37
 038            var entry = Get(userId);
 039            entry.Configure(entryModel);
 040            entry.SetButtonAction(OnUnblockUser);
 041        }
 42
 43        private void CreateEntry(string userId)
 44        {
 045            entryPool = GetEntryPool();
 046            var newFriendEntry = entryPool.Get();
 047            pooleableEntries.Add(userId, newFriendEntry);
 048            var entry = newFriendEntry.gameObject.GetComponent<BlockedUserEntry>();
 049            Add(userId, entry);
 050        }
 51
 52        private Pool GetEntryPool()
 53        {
 054            var entryPool = PoolManager.i.GetPool(POOL_NAME_PREFIX + name + GetInstanceID());
 055            if (entryPool != null) return entryPool;
 56
 057            entryPool = PoolManager.i.AddPool(
 58                POOL_NAME_PREFIX + name + GetInstanceID(),
 59                Instantiate(entryPrefab).gameObject,
 60                maxPrewarmCount: 20,
 61                isPersistent: true);
 062            entryPool.ForcePrewarm();
 63
 064            return entryPool;
 65        }
 66    }
 67}