| | 1 | | using System; |
| | 2 | |
|
| | 3 | | namespace DCL.Chat.HUD |
| | 4 | | { |
| | 5 | | public class ChannelLimitReachedWindowController : IDisposable |
| | 6 | | { |
| | 7 | | private readonly IChannelLimitReachedWindowView view; |
| | 8 | | private readonly DataStore dataStore; |
| | 9 | |
|
| 2 | 10 | | public ChannelLimitReachedWindowController(IChannelLimitReachedWindowView view, |
| | 11 | | DataStore dataStore) |
| | 12 | | { |
| 2 | 13 | | this.view = view; |
| 2 | 14 | | view.Hide(); |
| 2 | 15 | | view.OnClose += Close; |
| 2 | 16 | | this.dataStore = dataStore; |
| 2 | 17 | | dataStore.channels.currentChannelLimitReached.OnChange += Show; |
| 2 | 18 | | } |
| | 19 | |
|
| | 20 | | public void Dispose() |
| | 21 | | { |
| 0 | 22 | | dataStore.channels.currentChannelLimitReached.OnChange -= Show; |
| | 23 | |
|
| 0 | 24 | | if (view != null) |
| | 25 | | { |
| 0 | 26 | | view.OnClose -= Close; |
| 0 | 27 | | view.Dispose(); |
| | 28 | | } |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | private void Show(string currentChannelId, string previousChannelId) |
| | 32 | | { |
| 2 | 33 | | if (string.IsNullOrEmpty(currentChannelId)) return; |
| 2 | 34 | | view.Show(); |
| 2 | 35 | | } |
| | 36 | |
|
| 1 | 37 | | private void Close() => view.Hide(); |
| | 38 | | } |
| | 39 | | } |