< Summary

Class:PublicChannelEntry
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/PublicChannelEntry.cs
Covered lines:14
Uncovered lines:4
Coverable lines:18
Total lines:63
Line coverage:77.7% (14 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Awake()0%110100%
Initialize(...)0%2100%
Configure(...)0%110100%
RefreshControl()0%110100%
PublicChannelEntryModel(...)0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5using static PublicChannelEntry;
 6
 7public class PublicChannelEntry : BaseComponentView, IComponentModelConfig<PublicChannelEntryModel>
 8{
 9    [SerializeField] internal Button openChatButton;
 10    [SerializeField] internal TMP_Text nameLabel;
 11    [SerializeField] internal PublicChannelEntryModel model;
 12    [SerializeField] internal UnreadNotificationBadge unreadNotifications;
 13
 14    private IChatController chatController;
 15    private ILastReadMessagesService lastReadMessagesService;
 16
 017    public PublicChannelEntryModel Model => model;
 18
 19    public event Action<PublicChannelEntry> OnOpenChat;
 20
 21    public static PublicChannelEntry Create()
 22    {
 223        return Instantiate(Resources.Load<PublicChannelEntry>("SocialBarV1/PublicChannelElement"));
 24    }
 25
 26    public override void Awake()
 27    {
 2128        base.Awake();
 2329        openChatButton.onClick.AddListener(() => OnOpenChat?.Invoke(this));
 2130    }
 31
 32    public void Initialize(IChatController chatController,
 33        ILastReadMessagesService lastReadMessagesService)
 34    {
 035        this.chatController = chatController;
 036        this.lastReadMessagesService = lastReadMessagesService;
 037    }
 38
 39    public void Configure(PublicChannelEntryModel newModel)
 40    {
 1541        model = newModel;
 1542        RefreshControl();
 1543    }
 44
 45    public override void RefreshControl()
 46    {
 1547        nameLabel.text = $"#{model.name}";
 1548        unreadNotifications.Initialize(chatController, model.channelId, lastReadMessagesService);
 1549    }
 50
 51    [Serializable]
 52    public class PublicChannelEntryModel : BaseComponentModel
 53    {
 54        public string channelId;
 55        public string name;
 56
 1557        public PublicChannelEntryModel(string channelId, string name)
 58        {
 1559            this.channelId = channelId;
 1560            this.name = name;
 1561        }
 62    }
 63}