Beispiel #1
0
        private void OnChatRemoved(string chatId)
        {
            ModifyChatsSafely(() =>
            {
                var chatSummary = ChatsCollection.FirstOrDefault(x => x.ChatId == chatId);
                if (chatSummary != null)
                {
                    ChatsCollection.Remove(chatSummary);
                }
            });

            _messagesCache.RemoveMessagesAsync(chatId).FireAndForget();
        }
Beispiel #2
0
        private void OnChatUpdated(ChatSummaryModel updatedChatSummary)
        {
            if (updatedChatSummary == null)
            {
                return;
            }

            ModifyChatsSafely(() =>
            {
                var chatSummary = ChatsCollection.FirstOrDefault(x => x.ChatId == updatedChatSummary.Id);
                if (chatSummary != null)
                {
                    chatSummary.UpdateModel(updatedChatSummary);
                }
            });
        }
Beispiel #3
0
        public async Task <ChatSummaryViewModel> FindOrCreateDirectChatAsync(string memberId)
        {
            var directChatWithMember = ChatsCollection.FirstOrDefault(x =>
                                                                      x.Parameter.Type == ChannelType.Direct &&
                                                                      x.Parameter.DirectMember.Id == memberId);

            if (directChatWithMember != null)
            {
                return(directChatWithMember);
            }

            var directChatModel = await _chatService.CreateDirectChatAsync(memberId).ConfigureAwait(false);

            if (directChatModel == null)
            {
                return(null);
            }

            var directChatViewModel = _viewModelFactoryService.ResolveViewModel <ChatSummaryViewModel, ChatSummaryModel>(directChatModel);

            return(directChatViewModel);
        }
Beispiel #4
0
 public ChatSummaryViewModel GetChatById(string chatId)
 {
     return(ChatsCollection.FirstOrDefault(x => x.ChatId == chatId));
 }