< Summary

Class:DCL.Chat.HUD.ChannelLeaveErrorWindowController
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/ChannelLeaveErrorWindowController.cs
Covered lines:18
Uncovered lines:6
Coverable lines:24
Total lines:51
Line coverage:75% (18 of 24)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ChannelLeaveErrorWindowController(...)0%110100%
Dispose()0%6200%
Show(...)0%5.125083.33%
Close()0%110100%
Retry()0%110100%

File(s)

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

#LineLine coverage
 1namespace DCL.Chat.HUD
 2{
 3    public class ChannelLeaveErrorWindowController
 4    {
 5        private readonly IChannelLeaveErrorWindowView view;
 6        private readonly IChatController chatController;
 7        private readonly DataStore dataStore;
 8        private string currentChannelId;
 9
 310        public ChannelLeaveErrorWindowController(IChannelLeaveErrorWindowView view,
 11            IChatController chatController,
 12            DataStore dataStore)
 13        {
 314            this.view = view;
 315            this.chatController = chatController;
 316            view.Hide();
 317            view.OnClose += Close;
 318            view.OnRetry += Retry;
 319            this.dataStore = dataStore;
 320            dataStore.channels.leaveChannelError.OnChange += Show;
 321        }
 22
 23        public void Dispose()
 24        {
 025            dataStore.channels.leaveChannelError.OnChange -= Show;
 26
 027            if (view != null)
 28            {
 029                view.OnClose -= Close;
 030                view.OnRetry -= Retry;
 031                view.Dispose();
 32            }
 033        }
 34
 35        private void Show(string currentChannelId, string previousChannelId)
 36        {
 537            if (string.IsNullOrEmpty(currentChannelId)) return;
 538            this.currentChannelId = currentChannelId;
 539            var channel = chatController.GetAllocatedChannel(currentChannelId);
 540            view.Show(channel?.Name ?? currentChannelId);
 541        }
 42
 243        private void Close() => view.Hide();
 44
 45        private void Retry()
 46        {
 147            chatController.LeaveChannel(currentChannelId);
 148            Close();
 149        }
 50    }
 51}