< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ChannelJoinErrorWindowController(...)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/ChannelJoinErrorWindowController.cs

#LineLine coverage
 1using System;
 2
 3namespace DCL.Chat.HUD
 4{
 5    public class ChannelJoinErrorWindowController : IDisposable
 6    {
 7        private readonly IChannelJoinErrorWindowView view;
 8        private readonly IChatController chatController;
 9        private readonly DataStore dataStore;
 10        private string currentChannelId;
 11
 312        public ChannelJoinErrorWindowController(IChannelJoinErrorWindowView view,
 13            IChatController chatController,
 14            DataStore dataStore)
 15        {
 316            this.view = view;
 317            this.chatController = chatController;
 318            view.Hide();
 319            view.OnClose += Close;
 320            view.OnRetry += Retry;
 321            this.dataStore = dataStore;
 322            dataStore.channels.joinChannelError.OnChange += Show;
 323        }
 24
 25        public void Dispose()
 26        {
 027            dataStore.channels.joinChannelError.OnChange -= Show;
 28
 029            if (view != null)
 30            {
 031                view.OnClose -= Close;
 032                view.OnRetry -= Retry;
 033                view.Dispose();
 34            }
 035        }
 36
 37        private void Show(string currentChannelId, string previousChannelId)
 38        {
 539            if (string.IsNullOrEmpty(currentChannelId)) return;
 540            this.currentChannelId = currentChannelId;
 541            var channel = chatController.GetAllocatedChannel(currentChannelId);
 542            view.Show(channel?.Name ?? currentChannelId);
 543        }
 44
 245        private void Close() => view.Hide();
 46
 47        private void Retry()
 48        {
 149            chatController.JoinOrCreateChannel(currentChannelId);
 150            Close();
 151        }
 52    }
 53}