< Summary

Class:CollapsablePublicChannelListComponentView
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/CollapsablePublicChannelListComponentView.cs
Covered lines:20
Uncovered lines:3
Coverable lines:23
Total lines:62
Line coverage:86.9% (20 of 23)
Covered branches:0
Total branches:0
Covered methods:5
Total methods:6
Method coverage:83.3% (5 of 6)

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 DCL;
 2using System;
 3using System.Text.RegularExpressions;
 4using DCL.Social.Chat;
 5using DCL.Social.Chat;
 6using UIComponents.CollapsableSortedList;
 7using UnityEngine;
 8
 9public class CollapsablePublicChannelListComponentView : CollapsableSortedListComponentView<string, PublicChatEntry>
 10{
 11    [SerializeField] private ChannelEntryFactory entryFactory;
 12
 13    private IChatController chatController;
 14    private DataStore_Mentions mentionsDataStore;
 15
 16    public event Action<PublicChatEntry> OnOpenChat;
 17
 18    public void Initialize(
 19        IChatController chatController,
 20        DataStore_Mentions mentionsDataStore)
 21    {
 7422        this.chatController = chatController;
 7423        this.mentionsDataStore = mentionsDataStore;
 7424    }
 25
 26    public void Filter(string search)
 27    {
 028        var regex = new Regex(search, RegexOptions.IgnoreCase);
 029        Filter(entry => regex.IsMatch(entry.Model.name));
 030    }
 31
 32    public override PublicChatEntry Remove(string key)
 33    {
 934        var entry = base.Remove(key);
 35
 936        if (entry)
 837            Destroy(entry.gameObject);
 38
 939        return entry;
 40    }
 41
 42    public void Set(string channelId, PublicChatEntryModel entryModel)
 43    {
 3844        if (!Contains(entryModel.channelId))
 3245            CreateEntry(channelId);
 46
 3847        var entry = Get(channelId);
 3848        entry.Configure(entryModel);
 3849    }
 50
 51    private void CreateEntry(string channelId)
 52    {
 3253        var newFriendEntry = entryFactory.Create(channelId);
 3254        var entry = newFriendEntry.gameObject.GetComponent<PublicChatEntry>();
 3255        Add(channelId, entry);
 3256        entry.Initialize(chatController, mentionsDataStore);
 3257        entry.OnOpenChat -= HandleEntryOpenChat;
 3258        entry.OnOpenChat += HandleEntryOpenChat;
 3259    }
 60
 161    private void HandleEntryOpenChat(PublicChatEntry entry) => OnOpenChat?.Invoke(entry);
 62}