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