| | 1 | | using System; |
| | 2 | | using UIComponents.CollapsableSortedList; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL.Chat.HUD |
| | 6 | | { |
| | 7 | | public class CollapsableChatSearchListComponentView : CollapsableSortedListComponentView<string, BaseComponentView> |
| | 8 | | { |
| | 9 | | [SerializeField] private CollapsableDirectChatListComponentView directChatList; |
| | 10 | | [SerializeField] private CollapsablePublicChannelListComponentView publicChannelList; |
| | 11 | |
|
| | 12 | | public event Action<PrivateChatEntry> OnOpenPrivateChat |
| | 13 | | { |
| 40 | 14 | | add => directChatList.OnOpenChat += value; |
| 0 | 15 | | remove => directChatList.OnOpenChat += value; |
| | 16 | | } |
| | 17 | |
|
| | 18 | | public event Action<PublicChatEntry> OnOpenPublicChat |
| | 19 | | { |
| 40 | 20 | | add => publicChannelList.OnOpenChat += value; |
| 0 | 21 | | remove => publicChannelList.OnOpenChat -= value; |
| | 22 | | } |
| | 23 | |
|
| | 24 | | public void Initialize(IChatController chatController) |
| | 25 | | { |
| 34 | 26 | | directChatList.Initialize(chatController); |
| 34 | 27 | | publicChannelList.Initialize(chatController); |
| 34 | 28 | | } |
| | 29 | |
|
| | 30 | | public override void Filter(Func<BaseComponentView, bool> comparision) |
| | 31 | | { |
| 2 | 32 | | directChatList.Filter(comparision); |
| 2 | 33 | | publicChannelList.Filter(comparision); |
| 2 | 34 | | UpdateEmptyState(); |
| 2 | 35 | | } |
| | 36 | |
|
| | 37 | | public override int Count() |
| | 38 | | { |
| 286 | 39 | | return directChatList.Count() + publicChannelList.Count(); |
| | 40 | | } |
| | 41 | |
|
| | 42 | | public override void Clear() |
| | 43 | | { |
| 11 | 44 | | directChatList.Clear(); |
| 11 | 45 | | publicChannelList.Clear(); |
| 11 | 46 | | UpdateEmptyState(); |
| 11 | 47 | | } |
| | 48 | |
|
| | 49 | | public override BaseComponentView Get(string key) |
| | 50 | | { |
| 26 | 51 | | return (BaseComponentView) directChatList.Get(key) ?? publicChannelList.Get(key); |
| | 52 | | } |
| | 53 | |
|
| | 54 | | public override void Dispose() |
| | 55 | | { |
| 3 | 56 | | base.Dispose(); |
| 3 | 57 | | directChatList.Dispose(); |
| 3 | 58 | | publicChannelList.Dispose(); |
| 3 | 59 | | } |
| | 60 | |
|
| | 61 | | public override BaseComponentView Remove(string key) |
| | 62 | | { |
| 2 | 63 | | var entry = (BaseComponentView) directChatList.Remove(key) ?? publicChannelList.Remove(key); |
| 2 | 64 | | UpdateEmptyState(); |
| 2 | 65 | | return entry; |
| | 66 | | } |
| | 67 | |
|
| | 68 | | public void Set(PrivateChatEntryModel model) |
| | 69 | | { |
| 23 | 70 | | directChatList.Set(model.userId, model); |
| 23 | 71 | | directChatList.Get(model.userId).EnableAvatarSnapshotFetching(); |
| 23 | 72 | | UpdateEmptyState(); |
| 23 | 73 | | } |
| | 74 | |
|
| | 75 | | public void Set(PublicChatEntryModel model) |
| | 76 | | { |
| 12 | 77 | | publicChannelList.Set(model.channelId, model); |
| 12 | 78 | | UpdateEmptyState(); |
| 12 | 79 | | } |
| | 80 | | } |
| | 81 | | } |