[HTML] Add indication for pinned messages

Closes #193
pull/236/head
Alexey Golub 5 years ago
parent 9241b7d2d1
commit 2cdb230b1e

@ -29,9 +29,12 @@ namespace DiscordChatExporter.Core.Models
public IReadOnlyList<User> MentionedUsers { get; } public IReadOnlyList<User> MentionedUsers { get; }
public bool IsPinned { get; }
public Message(string id, string channelId, MessageType type, User author, DateTimeOffset timestamp, public Message(string id, string channelId, MessageType type, User author, DateTimeOffset timestamp,
DateTimeOffset? editedTimestamp, string content, IReadOnlyList<Attachment> attachments, DateTimeOffset? editedTimestamp, string content, IReadOnlyList<Attachment> attachments,
IReadOnlyList<Embed> embeds, IReadOnlyList<Reaction> reactions, IReadOnlyList<User> mentionedUsers) IReadOnlyList<Embed> embeds, IReadOnlyList<Reaction> reactions, IReadOnlyList<User> mentionedUsers,
bool isPinned)
{ {
Id = id; Id = id;
ChannelId = channelId; ChannelId = channelId;
@ -44,6 +47,7 @@ namespace DiscordChatExporter.Core.Models
Embeds = embeds; Embeds = embeds;
Reactions = reactions; Reactions = reactions;
MentionedUsers = mentionedUsers; MentionedUsers = mentionedUsers;
IsPinned = isPinned;
} }
public override string ToString() => Content; public override string ToString() => Content;

@ -54,6 +54,10 @@ a {
color: rgba(255, 255, 255, 0.2); color: rgba(255, 255, 255, 0.2);
} }
.chatlog__message--pinned {
background-color: rgba(249, 168, 37, 0.05);
}
.chatlog__edited-timestamp { .chatlog__edited-timestamp {
color: rgba(255, 255, 255, 0.2); color: rgba(255, 255, 255, 0.2);
} }

@ -55,6 +55,10 @@ a {
color: #99aab5; color: #99aab5;
} }
.chatlog__message--pinned {
background-color: rgba(249, 168, 37, 0.05);
}
.chatlog__edited-timestamp { .chatlog__edited-timestamp {
color: #99aab5; color: #99aab5;
} }

@ -179,8 +179,13 @@ img {
font-size: .75em; font-size: .75em;
} }
.chatlog__message {
padding: 2px 5px;
margin-right: -5px;
margin-left: -5px;
}
.chatlog__content { .chatlog__content {
padding-top: 5px;
font-size: .9375em; font-size: .9375em;
word-wrap: break-word; word-wrap: break-word;
} }
@ -190,20 +195,17 @@ img {
font-size: .8em; font-size: .8em;
} }
.chatlog__attachment {
margin: 5px 0;
}
.chatlog__attachment-thumbnail { .chatlog__attachment-thumbnail {
margin-top: 5px;
max-width: 50%; max-width: 50%;
max-height: 500px; max-height: 500px;
border-radius: 3px; border-radius: 3px;
} }
.chatlog__embed { .chatlog__embed {
margin-top: 5px;
display: flex; display: flex;
max-width: 520px; max-width: 520px;
margin-top: 5px;
} }
.chatlog__embed-color-pill { .chatlog__embed-color-pill {

@ -68,14 +68,17 @@
<div class="chatlog__messages"> <div class="chatlog__messages">
{{~ # Author name and timestamp ~}} {{~ # Author name and timestamp ~}}
<span class="chatlog__author-name" title="{{ group.Author.FullName | html.escape }}" data-user-id="{{ group.Author.Id | html.escape }}">{{ group.Author.Name | html.escape }}</span> <span class="chatlog__author-name" title="{{ group.Author.FullName | html.escape }}" data-user-id="{{ group.Author.Id | html.escape }}">{{ group.Author.Name | html.escape }}</span>
{{~ # Bot tag ~}}
{{~ if group.Author.IsBot ~}} {{~ if group.Author.IsBot ~}}
<span class="chatlog__bot-tag">BOT</span> <span class="chatlog__bot-tag">BOT</span>
{{~ end ~}} {{~ end ~}}
<span class="chatlog__timestamp">{{ group.Timestamp | FormatDate | html.escape }}</span> <span class="chatlog__timestamp">{{ group.Timestamp | FormatDate | html.escape }}</span>
{{~ # Messages ~}} {{~ # Messages ~}}
{{~ for message in group.Messages ~}} {{~ for message in group.Messages ~}}
<div class="chatlog__message" data-message-id="{{ message.Id }}"> <div class="chatlog__message {{if message.IsPinned }}chatlog__message--pinned{{ end }}" data-message-id="{{ message.Id }}">
{{~ # Content ~}} {{~ # Content ~}}
{{~ if message.Content ~}} {{~ if message.Content ~}}
<div class="chatlog__content"> <div class="chatlog__content">

@ -201,8 +201,11 @@ namespace DiscordChatExporter.Core.Services
// Get mentioned users // Get mentioned users
var mentionedUsers = json["mentions"].EmptyIfNull().Select(ParseUser).ToArray(); var mentionedUsers = json["mentions"].EmptyIfNull().Select(ParseUser).ToArray();
// Get whether this message is pinned
var isPinned = json["pinned"].Value<bool>();
return new Message(id, channelId, type, author, timestamp, editedTimestamp, content, attachments, embeds, return new Message(id, channelId, type, author, timestamp, editedTimestamp, content, attachments, embeds,
reactions, mentionedUsers); reactions, mentionedUsers, isPinned);
} }
} }
} }
Loading…
Cancel
Save