| | 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 void Initialize(IChatController chatController, ILastReadMessagesService lastReadMessagesService) |
| | 11 | | { |
| 23 | 12 | | directChatList.Initialize(chatController, lastReadMessagesService); |
| 23 | 13 | | publicChannelList.Initialize(chatController, lastReadMessagesService); |
| 23 | 14 | | } |
| | 15 | |
|
| | 16 | | public void Filter(string search) |
| | 17 | | { |
| 0 | 18 | | directChatList.Filter(search); |
| 0 | 19 | | publicChannelList.Filter(search); |
| 0 | 20 | | UpdateEmptyState(); |
| 0 | 21 | | } |
| | 22 | |
|
| | 23 | | public void Filter(Func<PrivateChatEntry, bool> privateComparision, |
| | 24 | | Func<PublicChannelEntry, bool> publicComparision) |
| | 25 | | { |
| 6 | 26 | | directChatList.Filter(privateComparision); |
| 6 | 27 | | publicChannelList.Filter(publicComparision); |
| 6 | 28 | | UpdateEmptyState(); |
| 6 | 29 | | } |
| | 30 | |
|
| | 31 | | public override void Filter(Func<BaseComponentView, bool> comparision) |
| | 32 | | { |
| 0 | 33 | | directChatList.Filter(comparision); |
| 0 | 34 | | publicChannelList.Filter(comparision); |
| 0 | 35 | | UpdateEmptyState(); |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | public override int Count() |
| | 39 | | { |
| 103 | 40 | | return directChatList.Count() + publicChannelList.Count(); |
| | 41 | | } |
| | 42 | |
|
| | 43 | | public void Clear(bool releaseEntriesFromPool) |
| | 44 | | { |
| 3 | 45 | | directChatList.Clear(releaseEntriesFromPool); |
| 3 | 46 | | publicChannelList.Clear(releaseEntriesFromPool); |
| 3 | 47 | | UpdateEmptyState(); |
| 3 | 48 | | } |
| | 49 | |
|
| | 50 | | public override void Clear() |
| | 51 | | { |
| 0 | 52 | | directChatList.Clear(); |
| 0 | 53 | | publicChannelList.Clear(); |
| 0 | 54 | | UpdateEmptyState(); |
| 0 | 55 | | } |
| | 56 | |
|
| | 57 | | public override BaseComponentView Get(string key) |
| | 58 | | { |
| 18 | 59 | | return (BaseComponentView) directChatList.Get(key) ?? publicChannelList.Get(key); |
| | 60 | | } |
| | 61 | |
|
| | 62 | | public override void Dispose() |
| | 63 | | { |
| 3 | 64 | | base.Dispose(); |
| 3 | 65 | | directChatList.Dispose(); |
| 3 | 66 | | publicChannelList.Dispose(); |
| 3 | 67 | | } |
| | 68 | |
|
| | 69 | | public override BaseComponentView Remove(string key) |
| | 70 | | { |
| 0 | 71 | | var view = (BaseComponentView) directChatList.Remove(key) ?? publicChannelList.Remove(key); |
| 0 | 72 | | UpdateEmptyState(); |
| 0 | 73 | | return view; |
| | 74 | | } |
| | 75 | |
|
| | 76 | | public void Set(PrivateChatEntry.PrivateChatEntryModel model) |
| | 77 | | { |
| 8 | 78 | | directChatList.Set(model.userId, model); |
| 8 | 79 | | UpdateEmptyState(); |
| 8 | 80 | | } |
| | 81 | |
|
| | 82 | | public void Export(CollapsablePublicChannelListComponentView publicChannelList, |
| | 83 | | CollapsableDirectChatListComponentView privateChatList) |
| | 84 | | { |
| 12 | 85 | | foreach (var pair in this.publicChannelList.Entries) |
| 3 | 86 | | publicChannelList.Add(pair.Key, pair.Value); |
| 24 | 87 | | foreach (var pair in directChatList.Entries) |
| 9 | 88 | | privateChatList.Add(pair.Key, pair.Value); |
| | 89 | |
|
| 3 | 90 | | Clear(false); |
| 3 | 91 | | } |
| | 92 | |
|
| | 93 | | public void Import(CollapsablePublicChannelListComponentView publicChannelList, |
| | 94 | | CollapsableDirectChatListComponentView privateChatList) |
| | 95 | | { |
| 40 | 96 | | foreach (var pair in privateChatList.Entries) |
| 14 | 97 | | directChatList.Add(pair.Key, pair.Value); |
| 24 | 98 | | foreach (var pair in publicChannelList.Entries) |
| 6 | 99 | | this.publicChannelList.Add(pair.Key, pair.Value); |
| | 100 | |
|
| 6 | 101 | | privateChatList.Clear(false); |
| 6 | 102 | | publicChannelList.Clear(false); |
| | 103 | |
|
| 6 | 104 | | UpdateEmptyState(); |
| 6 | 105 | | } |
| | 106 | | } |