| | 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 | | } |
| | 21 | |
|
| | 22 | | public void Filter(Func<PrivateChatEntry, bool> privateComparision, |
| | 23 | | Func<PublicChannelEntry, bool> publicComparision) |
| | 24 | | { |
| 6 | 25 | | directChatList.Filter(privateComparision); |
| 6 | 26 | | publicChannelList.Filter(publicComparision); |
| 6 | 27 | | } |
| | 28 | |
|
| | 29 | | public override void Filter(Func<BaseComponentView, bool> comparision) |
| | 30 | | { |
| 0 | 31 | | directChatList.Filter(comparision); |
| 0 | 32 | | publicChannelList.Filter(comparision); |
| 0 | 33 | | } |
| | 34 | |
|
| | 35 | | public override int Count() |
| | 36 | | { |
| 80 | 37 | | return directChatList.Count() + publicChannelList.Count(); |
| | 38 | | } |
| | 39 | |
|
| | 40 | | public void Clear(bool releaseEntriesFromPool) |
| | 41 | | { |
| 3 | 42 | | directChatList.Clear(releaseEntriesFromPool); |
| 3 | 43 | | publicChannelList.Clear(releaseEntriesFromPool); |
| 3 | 44 | | } |
| | 45 | |
|
| | 46 | | public override void Clear() |
| | 47 | | { |
| 0 | 48 | | directChatList.Clear(); |
| 0 | 49 | | publicChannelList.Clear(); |
| 0 | 50 | | } |
| | 51 | |
|
| | 52 | | public override BaseComponentView Get(string key) |
| | 53 | | { |
| 18 | 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 | | { |
| 0 | 66 | | return (BaseComponentView) directChatList.Remove(key) ?? publicChannelList.Remove(key); |
| | 67 | | } |
| | 68 | |
|
| 8 | 69 | | public void Set(PrivateChatEntry.PrivateChatEntryModel model) => directChatList.Set(model.userId, model); |
| | 70 | |
|
| | 71 | | public void Export(CollapsablePublicChannelListComponentView publicChannelList, |
| | 72 | | CollapsableDirectChatListComponentView privateChatList) |
| | 73 | | { |
| 12 | 74 | | foreach (var pair in this.publicChannelList.Entries) |
| 3 | 75 | | publicChannelList.Add(pair.Key, pair.Value); |
| 24 | 76 | | foreach (var pair in directChatList.Entries) |
| 9 | 77 | | privateChatList.Add(pair.Key, pair.Value); |
| | 78 | |
|
| 3 | 79 | | Clear(false); |
| 3 | 80 | | } |
| | 81 | |
|
| | 82 | | public void Import(CollapsablePublicChannelListComponentView publicChannelList, |
| | 83 | | CollapsableDirectChatListComponentView privateChatList) |
| | 84 | | { |
| 40 | 85 | | foreach (var pair in privateChatList.Entries) |
| 14 | 86 | | directChatList.Add(pair.Key, pair.Value); |
| 24 | 87 | | foreach (var pair in publicChannelList.Entries) |
| 6 | 88 | | this.publicChannelList.Add(pair.Key, pair.Value); |
| | 89 | |
|
| 6 | 90 | | privateChatList.Clear(false); |
| 6 | 91 | | publicChannelList.Clear(false); |
| 6 | 92 | | } |
| | 93 | | } |