< Summary

Class:CollapsablePublicChannelListComponentView
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/CollapsablePublicChannelListComponentView.cs
Covered lines:19
Uncovered lines:3
Coverable lines:22
Total lines:56
Line coverage:86.3% (19 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize(...)0%110100%
Filter(...)0%2100%
Remove(...)0%220100%
Set(...)0%220100%
CreateEntry(...)0%110100%
HandleEntryOpenChat(...)0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/CollapsablePublicChannelListComponentView.cs

#LineLine coverage
 1using System;
 2using System.Text.RegularExpressions;
 3using DCL.Chat.HUD;
 4using UIComponents.CollapsableSortedList;
 5using UnityEngine;
 6
 7public class CollapsablePublicChannelListComponentView : CollapsableSortedListComponentView<string, PublicChatEntry>
 8{
 9    [SerializeField] private ChannelEntryFactory entryFactory;
 10
 11    private IChatController chatController;
 12
 13    public event Action<PublicChatEntry> OnOpenChat;
 14
 15    public void Initialize(IChatController chatController)
 16    {
 6817        this.chatController = chatController;
 6818    }
 19
 20    public void Filter(string search)
 21    {
 022        var regex = new Regex(search, RegexOptions.IgnoreCase);
 023        Filter(entry => regex.IsMatch(entry.Model.name));
 024    }
 25
 26    public override PublicChatEntry Remove(string key)
 27    {
 928        var entry = base.Remove(key);
 29
 930        if (entry)
 831            Destroy(entry.gameObject);
 32
 933        return entry;
 34    }
 35
 36    public void Set(string channelId, PublicChatEntryModel entryModel)
 37    {
 3838        if (!Contains(entryModel.channelId))
 3239            CreateEntry(channelId);
 40
 3841        var entry = Get(channelId);
 3842        entry.Configure(entryModel);
 3843    }
 44
 45    private void CreateEntry(string channelId)
 46    {
 3247        var newFriendEntry = entryFactory.Create(channelId);
 3248        var entry = newFriendEntry.gameObject.GetComponent<PublicChatEntry>();
 3249        Add(channelId, entry);
 3250        entry.Initialize(chatController);
 3251        entry.OnOpenChat -= HandleEntryOpenChat;
 3252        entry.OnOpenChat += HandleEntryOpenChat;
 3253    }
 54
 155    private void HandleEntryOpenChat(PublicChatEntry entry) => OnOpenChat?.Invoke(entry);
 56}