Exemple #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());
 }
Exemple #2
0
        private async Task LoadRepliesAsync(TopicNode topic)
        {
            var messageMap =
                (await _api.Client.Messages.GetMessagesAsync(topicID: topic.Message.ID, withRates: true, withReadMarks: true))
                .Items
                .GroupBy(m => m.ParentID)
                .ToDictionary(grp => grp.Key, grp => grp.ToArray());

            topic.Children = BuildTopicTree(messageMap, 0, topic, topic);
            topic.IsLoaded = true;
        }