using System; 
 | 
using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using System.Linq; 
 | 
using UnityEngine; 
 | 
    public class ChatRecently : MonoBehaviour 
 | 
    { 
 | 
        [SerializeField] ScrollerController m_RecentlyControl; 
 | 
  
 | 
        // FriendsModel m_FriendModel; 
 | 
        // FriendsModel friendModel 
 | 
        // { 
 | 
        //     get 
 | 
        //     { 
 | 
        //         return m_FriendModel ?? (m_FriendModel = ModelCenter.Instance.GetModel<FriendsModel>()); 
 | 
        //     } 
 | 
        // } 
 | 
  
 | 
        private void OnEnable() 
 | 
        { 
 | 
            UpdatePlayer(); 
 | 
            DisplayRecently(); 
 | 
            // friendModel.RefreshFriendCntEvent += RefreshFriendCntEvent; 
 | 
            // friendModel.RefreshFriendModel += DisplayRecently; 
 | 
        } 
 | 
  
 | 
        private void OnDisable() 
 | 
        { 
 | 
            // friendModel.RefreshFriendCntEvent -= RefreshFriendCntEvent; 
 | 
            // friendModel.RefreshFriendModel -= DisplayRecently; 
 | 
        } 
 | 
  
 | 
        private void DisplayRecently() 
 | 
        { 
 | 
            m_RecentlyControl.Refresh(); 
 | 
            // var _dict = friendModel.GetFriendInfoDict((byte)GroupType.RecentContact); 
 | 
            // if (_dict != null) 
 | 
            // { 
 | 
            //     if (friendModel.tempFriendData != null && !_dict.ContainsKey(friendModel.tempFriendData.PlayerID)) 
 | 
            //     { 
 | 
            //         m_RecentlyControl.AddCell(ScrollerDataType.Header, (int)friendModel.tempFriendData.PlayerID, OnClickFriend); 
 | 
            //     } 
 | 
            //     foreach (var _id in _dict.Keys) 
 | 
            //     { 
 | 
            //         m_RecentlyControl.AddCell(ScrollerDataType.Header, (int)_id, OnClickFriend); 
 | 
            //     } 
 | 
            // } 
 | 
            // else if (friendModel.tempFriendData != null) 
 | 
            // { 
 | 
            //     m_RecentlyControl.AddCell(ScrollerDataType.Header, (int)friendModel.tempFriendData.PlayerID, OnClickFriend); 
 | 
            // } 
 | 
            m_RecentlyControl.Restart(); 
 | 
        } 
 | 
  
 | 
        private void OnClickFriend(CellView _cell) 
 | 
        { 
 | 
            // if(_cell.index!= ChatManager.Instance.PteChatID) 
 | 
            // { 
 | 
            //     ChatManager.Instance.PteChatID = _cell.index; 
 | 
            //     var _dict = friendModel.GetFriendInfoDict((byte)GroupType.RecentContact); 
 | 
            //     if (friendModel.tempFriendData != null 
 | 
            //         && ChatManager.Instance.PteChatID == friendModel.tempFriendData.PlayerID) 
 | 
            //     { 
 | 
            //         ChatManager.Instance.PteChatName = friendModel.tempFriendData.PlayerName; 
 | 
            //         LanguageVerify.toPlayerLevel = friendModel.tempFriendData.LV; 
 | 
            //     } 
 | 
            //     else 
 | 
            //     { 
 | 
            //         ChatManager.Instance.PteChatName = _dict != null && _dict.ContainsKey((uint)ChatManager.Instance.PteChatID) ? 
 | 
            //                         _dict[(uint)ChatManager.Instance.PteChatID].PlayerName : string.Empty; 
 | 
            //         LanguageVerify.toPlayerLevel = _dict != null && _dict.ContainsKey((uint)ChatManager.Instance.PteChatID) ? 
 | 
            //                         _dict[(uint)ChatManager.Instance.PteChatID].LV : 0; 
 | 
            //     } 
 | 
            //     ChatManager.Instance.SelectRecentlyChat(ChatManager.Instance.PteChatID); 
 | 
            //     m_RecentlyControl.m_Scorller.RefreshActiveCellViews(); 
 | 
            // } 
 | 
        } 
 | 
  
 | 
        private void RefreshFriendCntEvent(/*GroupType _type, bool arg2*/) 
 | 
        { 
 | 
            // if (_type == GroupType.RecentContact) 
 | 
            // { 
 | 
            //     DisplayRecently(); 
 | 
            // } 
 | 
        } 
 | 
  
 | 
        private void UpdatePlayer() 
 | 
        { 
 | 
            // TODO YYL 
 | 
            // if (friendModel.tempFriendData != null) 
 | 
            // { 
 | 
            //     ChatManager.Instance.PteChatID = (int)friendModel.tempFriendData.PlayerID; 
 | 
            //     ChatManager.Instance.PteChatName = friendModel.tempFriendData.PlayerName; 
 | 
            //     LanguageVerify.toPlayerLevel = friendModel.tempFriendData.LV; 
 | 
            //     ChatManager.Instance.SelectRecentlyChat(ChatManager.Instance.PteChatID); 
 | 
            //     return; 
 | 
            // } 
 | 
            // var _dict = friendModel.GetFriendInfoDict((byte)GroupType.RecentContact); 
 | 
            // if (_dict != null && _dict.Count > 0) 
 | 
            // { 
 | 
            //     ChatManager.Instance.PteChatID = (int)_dict.Keys.First(); 
 | 
            //     ChatManager.Instance.PteChatName = _dict[(uint)ChatManager.Instance.PteChatID].PlayerName; 
 | 
            //     LanguageVerify.toPlayerLevel = _dict[(uint)ChatManager.Instance.PteChatID].LV; 
 | 
            //     ChatManager.Instance.SelectRecentlyChat(ChatManager.Instance.PteChatID); 
 | 
            // } 
 | 
        } 
 | 
    } 
 |