예제 #1
0
        async void item_CommentsRequested(object sender, EventArgs e)
        {
            var item = (SampleDataItem)sender;

            item.CommentsRequested -= item_CommentsRequested;

            item.Replies.Add(item.ToTopReplyItem());

            var localReplies = await localStorageService.LoadReplies(item.MId);

            if (localReplies != null)
            {
                ClearTail(item.Replies);
                foreach (var localReply in localReplies)
                {
                    item.Replies.Add(CreateSampleDataReplyItem(item, localReply, null));
                }
            }
            try {
                var replies = await client.GetReplies(item.MId);

                if (replies != null)
                {
                    ClearTail(item.Replies);
                    foreach (var reply in replies)
                    {
                        var photoUrl = reply.Photo != null
                            ? reply.Photo.Medium
                            : null;
                        var commentItem = CreateSampleDataReplyItem(item, reply, photoUrl);
                        item.Replies.Add(commentItem);
                    }
                }
            } catch {
                // todo: show error message
            }
        }