From bd46bc62ffdac9428ff606945937c4b0c3850f3c Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 5 Jul 2016 12:11:48 +1000 Subject: [PATCH] FEATURE: show like button to anon --- app/assets/javascripts/discourse/lib/transform-post.js.es6 | 4 ++++ app/assets/javascripts/discourse/templates/topic.hbs | 1 + app/assets/javascripts/discourse/widgets/post-menu.js.es6 | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/app/assets/javascripts/discourse/lib/transform-post.js.es6 b/app/assets/javascripts/discourse/lib/transform-post.js.es6 index 77238979707..03ff394ec38 100644 --- a/app/assets/javascripts/discourse/lib/transform-post.js.es6 +++ b/app/assets/javascripts/discourse/lib/transform-post.js.es6 @@ -194,6 +194,10 @@ export default function transformPost(currentUser, site, post, prevPost, nextPos postAtts.likeCount = likeAction.count; } + if (!currentUser) { + postAtts.showLike = !topic.archived; + } + if (postAtts.post_number === 1) { postAtts.canRecoverTopic = topic.deleted_at && details.can_recover; postAtts.canDeleteTopic = !topic.deleted_at && details.can_delete; diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs index 086fc13642f..b7dc9347a2a 100644 --- a/app/assets/javascripts/discourse/templates/topic.hbs +++ b/app/assets/javascripts/discourse/templates/topic.hbs @@ -98,6 +98,7 @@ showFlags="showFlags" editPost="editPost" showHistory="showHistory" + showLogin="showLogin" showRawEmail="showRawEmail" deletePost="deletePost" recoverPost="recoverPost" diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 index f8b6f6f40a3..35102e59760 100644 --- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 @@ -1,6 +1,7 @@ import { createWidget } from 'discourse/widgets/widget'; import { avatarAtts } from 'discourse/widgets/actions-summary'; import { h } from 'virtual-dom'; +import User from 'discourse/models/user'; const LIKE_ACTION = 2; @@ -307,6 +308,9 @@ export default createWidget('post-menu', { }, like() { + if (!User.current()) { + return this.sendWidgetAction('showLogin'); + } const attrs = this.attrs; if (attrs.liked) { return this.sendWidgetAction('toggleLike');