Example #1
0
        internal Conversation(ConversationState conversationState)
        {
            _synchronizationContext = Client.CurrentSynchronizationContext;

            _conversation = conversationState.conversation;
            if (_conversation.read_state.Count > 0)
                ReadState = _conversation.read_state.Last(c=>c.latest_read_timestamp > 0).latest_read_timestamp.FromUnixTime();
            if (_conversation.self_conversation_state.self_read_state != null)
                SelfReadState = _conversation.self_conversation_state.self_read_state.latest_read_timestamp.FromUnixTime();
            Participants = _conversation.participant_data.ToDictionary(c=>c.id.chat_id, c => new Participant(c));
            MessagesHistory = new ObservableCollection<Message>();

            foreach(var cse in conversationState.events.Where(c=>c.chat_message != null))
            {
                messagesIds.Add(cse.event_id, cse.timestamp);
                if (_lastMessage != null && _lastMessage.SenderId == cse.sender_id.gaia_id)
                    _lastMessage.AddContent(cse);
                else
                {
                    _lastMessage = new Message(cse);
                    MessagesHistory.Add(_lastMessage);
                }

            }
        }
Example #2
0
        internal Conversation(ConversationState conversationState)
        {
            _synchronizationContext = Client.CurrentSynchronizationContext;

            _conversation = conversationState.conversation;
            if (_conversation.read_state.Count > 0)
            {
                ReadState = _conversation.read_state.Last(c => c.latest_read_timestamp > 0).latest_read_timestamp.FromUnixTime();
            }
            if (_conversation.self_conversation_state.self_read_state != null)
            {
                SelfReadState = _conversation.self_conversation_state.self_read_state.latest_read_timestamp.FromUnixTime();
            }
            Participants    = _conversation.participant_data.ToDictionary(c => c.id.chat_id, c => new Participant(c));
            MessagesHistory = new ObservableCollection <Message>();

            foreach (var cse in conversationState.events.Where(c => c.chat_message != null))
            {
                if (_lastMessage != null && _lastMessage.SenderId == cse.sender_id.gaia_id)
                {
                    _lastMessage.AppendContent(cse);
                }
                else
                {
                    _lastMessage = new Message(cse);
                    MessagesHistory.Add(_lastMessage);
                }
            }
        }
Example #3
0
        internal Conversation(ConversationState conversationState)
        {
            _conversation = conversationState.conversation;
            if (_conversation.read_state.Count > 0)
            {
                ReadState = DateTime.Now.FromMillisecondsSince1970(_conversation.read_state.Last().latest_read_timestamp / 1000);
            }

            Participants     = _conversation.participant_data.ToDictionary(c => c.id.chat_id, c => new Participant(c));
            ParticipantsName = string.Join <string>(", ", _conversation.participant_data.Select(c => c.fallback_name));
            MessagesHistory  = new ObservableCollection <Message>();

            foreach (var cse in conversationState.events.Where(c => c.chat_message != null))
            {
                if (_lastMessage != null && _lastMessage.SenderId == cse.sender_id.chat_id)
                {
                    _lastMessage.AppendContent(cse.chat_message);
                }
                else
                {
                    _lastMessage = new Message(cse);
                    MessagesHistory.Add(_lastMessage);
                }
                LastMessage = cse.chat_message.message_content.segment.Last().text;
            }
        }
Example #4
0
        public Conversation(ConversationState conversationState)
        {
            _conversation = conversationState.conversation;            
            Participants = _conversation.participant_data.ToDictionary(c=>c.id.chat_id, c => new Participant(c));
            MessagesHistory = new List<Message>();
            Message message = null;
            foreach(var cse in conversationState.events.Where(c=>c.chat_message != null))
            {                
                if (message != null && message.SenderId == cse.sender_id.chat_id)
                    message.AppendContent(cse.chat_message);
                else 
                {
                    message = new Message(Participants[cse.sender_id.chat_id], cse.chat_message);
                    MessagesHistory.Add(message);
                }
            }

            
                        
        }
Example #5
0
        public Conversation(ConversationState conversationState)
        {
            _conversation   = conversationState.conversation;
            Participants    = _conversation.participant_data.ToDictionary(c => c.id.chat_id, c => new Participant(c));
            MessagesHistory = new List <Message>();
            Message message = null;

            foreach (var cse in conversationState.events.Where(c => c.chat_message != null))
            {
                if (message != null && message.SenderId == cse.sender_id.chat_id)
                {
                    message.AppendContent(cse.chat_message);
                }
                else
                {
                    message = new Message(Participants[cse.sender_id.chat_id], cse.chat_message);
                    MessagesHistory.Add(message);
                }
            }
        }