Esempio n. 1
0
 private MessageNode[] BuildTopicTree(
     IReadOnlyDictionary <int, MessageInfo[]> messageMap,
     int level,
     TopicNode topic,
     MessageNode parent)
 {
     if (!messageMap.TryGetValue(parent.Message.ID, out var children))
     {
         return(Array.Empty <MessageNode>());
     }
     level += 1;
     return(children
            .Select(c =>
     {
         var res = new MessageNode(c.IsRead, MarkMessageReadAsync)
         {
             Message = c,
             Level = level,
             TopicNode = topic,
             ParentNode = parent
         };
         res.Children = BuildTopicTree(messageMap, level, topic, res);
         return res;
     })
            .ToArray());
 }
Esempio n. 2
0
        private async Task MarkMessageReadAsync(MessageNode msg)
        {
            if (msg.IsRead == true || msg.Message.ID != Message.Message.ID)
            {
                return;
            }
            await _api.Client.ReadMarks.AddReadMarksAsync(new [] { msg.Message.ID });

            if (msg.TopicNode != null)
            {
                lock (msg.TopicNode)
                    msg.TopicNode.TopicUnreadCount = msg.TopicNode.TopicUnreadCount - 1;
            }
            msg.IsRead = true;
        }