< Summary

Class:DCL.Chat.HUD.PublicChatEntry
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/PublicChatEntry.cs
Covered lines:33
Uncovered lines:0
Coverable lines:33
Total lines:86
Line coverage:100% (33 of 33)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PublicChatEntry()0%110100%
Create()0%110100%
Awake()0%440100%
Initialize(...)0%110100%
Configure(...)0%110100%
RefreshControl()0%990100%
Dock(...)0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6namespace DCL.Chat.HUD
 7{
 8    public class PublicChatEntry : BaseComponentView, IComponentModelConfig<PublicChatEntryModel>
 9    {
 10        [SerializeField] internal Button openChatButton;
 11        [SerializeField] internal TMP_Text nameLabel;
 12        [SerializeField] internal PublicChatEntryModel model;
 13        [SerializeField] internal UnreadNotificationBadge unreadNotifications;
 6114        [SerializeField] internal string namePrefix = "#";
 15        [SerializeField] internal TMP_Text memberCountLabel;
 16        [SerializeField] internal Button optionsButton;
 17        [SerializeField] internal Button leaveButton;
 18        [SerializeField] internal Button joinButton;
 19        [SerializeField] internal GameObject leaveButtonContainer;
 20        [SerializeField] internal GameObject openChatContainer;
 21        [SerializeField] internal GameObject joinedContainer;
 22        [SerializeField] internal Toggle muteNotificationsToggle;
 23
 24        private IChatController chatController;
 25
 526        public PublicChatEntryModel Model => model;
 27
 28        public event Action<PublicChatEntry> OnOpenChat;
 29        public event Action<PublicChatEntry> OnLeave;
 30        public event Action<PublicChatEntry> OnJoin;
 31        public event Action<PublicChatEntry> OnOpenOptions;
 32
 33        public static PublicChatEntry Create()
 34        {
 735            return Instantiate(Resources.Load<PublicChatEntry>("SocialBarV1/PublicChannelElement"));
 36        }
 37
 38        public override void Awake()
 39        {
 5340            base.Awake();
 5641            openChatButton.onClick.AddListener(() => OnOpenChat?.Invoke(this));
 42
 5343            if (optionsButton)
 2944                optionsButton.onClick.AddListener(() => OnOpenOptions?.Invoke(this));
 45
 5346            if (leaveButton)
 2847                leaveButton.onClick.AddListener(() => OnLeave?.Invoke(this));
 48
 5349            if (joinButton)
 2650                joinButton.onClick.AddListener(() => OnJoin?.Invoke(this));
 5351        }
 52
 53        public void Initialize(IChatController chatController)
 54        {
 3755            this.chatController = chatController;
 3756        }
 57
 58        public void Configure(PublicChatEntryModel newModel)
 59        {
 5360            model = newModel;
 5361            RefreshControl();
 5362        }
 63
 64        public override void RefreshControl()
 65        {
 5366            nameLabel.text = $"{namePrefix}{model.name}";
 5367            if (unreadNotifications)
 2968                unreadNotifications.Initialize(chatController, model.channelId);
 5369            if (memberCountLabel)
 5370                memberCountLabel.SetText($"{model.memberCount} members {(model.showOnlyOnlineMembers ? "online" : "joine
 5371            if (joinedContainer)
 2472                joinedContainer.SetActive(model.isJoined);
 5373            if (leaveButtonContainer)
 2474                leaveButtonContainer.SetActive(model.isJoined);
 5375            if (openChatContainer)
 2476                openChatContainer.SetActive(!model.isJoined);
 5377            if (muteNotificationsToggle)
 2978                muteNotificationsToggle.SetIsOnWithoutNotify(model.muted);
 5379        }
 80
 81        public void Dock(ChannelContextualMenu contextualMenu)
 82        {
 183            contextualMenu.transform.position = optionsButton.transform.position;
 184        }
 85    }
 86}