Ejemplo n.º 1
0
        internal void AddPreviousMessages(IEnumerable <ChatMessageViewModel> messages)
        {
            bool hasUpdates = false;

            _messages.IsNotifying = false;

            foreach (var chatMessage in messages.Reverse())
            {
                chatMessage.HasBeenSeen = true;
                var firstMessageGroup = _messages.FirstOrDefault() as ChatMessageGroupViewModel;
                if (firstMessageGroup == null || !firstMessageGroup.TryAddPreviousMessage(chatMessage))
                {
                    var groupMessage = new ChatMessageGroupViewModel(chatMessage);
                    _messages.Insert(0, groupMessage);

                    hasUpdates = true;
                }
            }

            _messages.IsNotifying = true;

            if (hasUpdates)
            {
                _messages.Refresh();
            }

            IsRequestingPreviousMessages = false;
        }
Ejemplo n.º 2
0
        internal void ProcessMessage(ChatMessageViewModel viewModel, bool suppressUnreadNotifications = false)
        {
            viewModel.HasBeenSeen = IsRoomVisible(suppressUnreadNotifications);

            var lastGroupMessage = _messages.LastOrDefault() as ChatMessageGroupViewModel;

            if (lastGroupMessage == null || !lastGroupMessage.TryAddMessage(viewModel))
            {
                var groupViewModel = new ChatMessageGroupViewModel(viewModel);
                _messages.Add(groupViewModel);
            }

            UpdateUnreadMessageCount();
        }