public void ProcessNewMessage(MessageModel messageModel) { logger.info("processing message and adding to observable collection"); if (messageModel is MessageModelDelivered) { MessageModelDelivered newMessage = (MessageModelDelivered) messageModel; var selectedMessages = from message in messages where message is MessageModelDelivered && ((MessageModelDelivered) message).Id == messageModel.Id select message; if (selectedMessages.Any()) { logger.info("message with this ID already in list"); return; } } messages.Add(messageModel); Peer peer = Peer; if (peer.Constructor == Constructor.peerUser) { if (userTyping != null) { userTyping = null; } } else if (peer.Constructor == Constructor.peerChat) { if (chatTyping.Count != 0) { chatTyping.Clear(); } } OnPropertyChanged("PreviewOrAction"); OnPropertyChanged("StatusOrAction"); OnPropertyChanged("MessageDeliveryStateProperty"); }
private async Task DelayedDestroyMessage(MessageModel message) { await Task.Delay(TimeSpan.FromSeconds(ttl)); if(messages.Contains(message)) { messages.Remove(message); } }
private async Task DoDeleteMessage(MessageModel message) { List<int> idsDeleted = await TelegramSession.Instance.Api.messages_deleteMessages(new List<int>(message.Id)); if (idsDeleted.Count > 0) { model.Messages.Remove(message); } }