Show message edits

pull/4/head
Alexey Golub 7 years ago
parent 460a319a45
commit 8662c8da04

@ -10,16 +10,19 @@ namespace DiscordChatExporter.Models
public DateTime TimeStamp { get; }
public DateTime? EditedTimeStamp { get; }
public User Author { get; }
public string Content { get; }
public IReadOnlyList<Attachment> Attachments { get; }
public Message(string id, DateTime timeStamp, User author, string content, IEnumerable<Attachment> attachments)
public Message(string id, DateTime timeStamp, DateTime? editedTimeStamp, User author, string content, IEnumerable<Attachment> attachments)
{
Id = id;
TimeStamp = timeStamp;
EditedTimeStamp = editedTimeStamp;
Author = author;
Content = content;
Attachments = attachments.ToArray();

@ -21,6 +21,7 @@ namespace DiscordChatExporter.Services
// Get basic data
string id = messageJson.Value<string>("id");
var timeStamp = messageJson.Value<DateTime>("timestamp");
var editedTimeStamp = messageJson.Value<DateTime?>("edited_timestamp");
string content = messageJson.Value<string>("content");
// Get author
@ -44,7 +45,7 @@ namespace DiscordChatExporter.Services
}
var author = new User(authorId, authorName, authorAvatarHash);
var message = new Message(id, timeStamp, author, content, attachments);
var message = new Message(id, timeStamp, editedTimeStamp, author, content, attachments);
yield return message;
}

@ -155,7 +155,15 @@ namespace DiscordChatExporter.Services
if (message.Content.IsNotBlank())
{
string content = FormatMessageContent(message.Content);
messageBodyHtml.AppendChild(HtmlNode.CreateNode($"<div class=\"msg-content\">{content}</div>"));
var contentHtml = messageBodyHtml.AppendChild(HtmlNode.CreateNode($"<div class=\"msg-content\">{content}</div>"));
// Is edited
if (message.EditedTimeStamp != null)
{
contentHtml.AppendChild(
HtmlNode.CreateNode(
$"<span class=\"msg-edited\" title=\"{message.EditedTimeStamp:g}\">(edited)</span>"));
}
}
// Attachments

@ -62,6 +62,12 @@
font-size: 0.8em;
font-weight: 200;
}
span.msg-edited {
margin-left: 5px;
color: #b7bcbf;
font-size: 0.8em;
font-weight: 200;
}
div.msg-content {
padding-top: 5px;
color: #939799;

Loading…
Cancel
Save