public void channelsCallback(List <Message> messages, bool is_deleted = false) { if (messages != null) { foreach (Message message in messages) { if (message == null) { continue; } if (message.machine_only || string.IsNullOrEmpty(message.text)) { continue; } if (message.channel_id != "net.app.core.pm") { // PM for now continue; } if (!message.is_deleted) { ApnItem item = new ApnItem(message, this); item.receivingAccount = this; PrivateMessages.Add(item); } else { IEnumerable <ApnItem> existing_items = PrivateMessages.Where(item => item.Id.ToString() == message.id); if (existing_items != null) { if (existing_items.Count() > 0) { List <ApnItem> cache = new List <ApnItem>(); foreach (ApnItem item in existing_items) { cache.Add(item); } foreach (ApnItem item in cache) { PrivateMessages.Remove(item); } cache = null; } } } } } }