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