blog3000/Blog3000/Client/Shared/TopicContent.razor.cs

41 lines
959 B
C#

using Microsoft.AspNetCore.Components;
using Blog3000.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Blog3000.Client.Shared
{
public partial class TopicContent
{
[Parameter]
public TopTopics.Topic Topic { get; set; }
[Parameter]
public TopTopics Owner { get; set; }
private List<BlogPostHeader> sortedPosts;
protected override void OnInitialized()
{
var s = new List<BlogPostHeader>(Topic?.Posts);
s.Sort((a, b) => DateTime.Compare(
b.Revisions?.Latest()?.ChangedAt ?? DateTime.MinValue,
a.Revisions?.Latest()?.ChangedAt ?? DateTime.MinValue));
sortedPosts = s.Take(5).ToList();
}
private void TopicClicked(string topic)
{
//System.Diagnostics.Debug.WriteLine(topic);
Owner?.OnTopicClick.InvokeAsync(topic);
}
}
}