UX: show date of last edit on wiki topics

This commit is contained in:
Régis Hanol
2017-09-12 15:37:47 +02:00
parent 07bfe3d053
commit 85ef3696de
4 changed files with 26 additions and 12 deletions
@@ -35,6 +35,7 @@ export function transformBasicPost(post) {
primary_group_flair_bg_color: post.primary_group_flair_bg_color,
primary_group_flair_color: post.primary_group_flair_color,
wiki: post.wiki,
lastWikiEdit: post.last_wiki_edit,
firstPost: post.post_number === 1,
post_number: post.post_number,
cooked: post.cooked,
@@ -171,19 +171,22 @@ createWidget('post-meta-data', {
}, iconNode('eye-slash')));
}
const lastWikiEdit = attrs.wiki && attrs.lastWikiEdit && new Date(attrs.lastWikiEdit);
const createdAt = new Date(attrs.created_at);
if (createdAt) {
result.push(h('div.post-info',
h('a.post-date', {
attributes: {
href: attrs.shareUrl,
'data-share-url': attrs.shareUrl,
'data-post-number': attrs.post_number,
}
}, dateNode(createdAt))
));
const date = lastWikiEdit ? dateNode(lastWikiEdit) : dateNode(createdAt);
const attributes = {
class: "post-date",
href: attrs.shareUrl,
'data-share-url': attrs.shareUrl,
'data-post-number': attrs.post_number
};
if (lastWikiEdit) {
attributes["class"] += " last-wiki-edit";
}
result.push(h('div.post-info', h('a', { attributes }, date)));
if (attrs.via_email) {
result.push(this.attach('post-email-indicator', attrs));
}