From 619737d20915b51e09c65dc1f60cdeb2f93d0874 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 3 Mar 2017 16:58:07 -0500 Subject: [PATCH] FEATURE: remove "liking" on OP for topics with voting --- .../extend-category-for-voting.js.es6 | 9 ++++++++- assets/stylesheets/feature-voting.scss | 4 ++++ plugin.rb | 13 +++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/discourse/pre-initializers/extend-category-for-voting.js.es6 b/assets/javascripts/discourse/pre-initializers/extend-category-for-voting.js.es6 index 212131a..383dba7 100644 --- a/assets/javascripts/discourse/pre-initializers/extend-category-for-voting.js.es6 +++ b/assets/javascripts/discourse/pre-initializers/extend-category-for-voting.js.es6 @@ -3,6 +3,13 @@ import Category from 'discourse/models/category'; import { withPluginApi } from 'discourse/lib/plugin-api'; function initialize(api) { + + api.addPostClassesCallback((post) => { + if (post.post_number === 1 && post.can_vote) { + return ["voting-post"]; + } + }); + api.includePostAttributes('can_vote'); api.addTagsHtmlCallback((topic) => { if (!topic.can_vote) { return; } @@ -33,7 +40,7 @@ export default { before: 'inject-discourse-objects', initialize(container) { - withPluginApi('0.8.3', api => { + withPluginApi('0.8.4', api => { initialize(api, container); }); diff --git a/assets/stylesheets/feature-voting.scss b/assets/stylesheets/feature-voting.scss index de3169e..049befe 100644 --- a/assets/stylesheets/feature-voting.scss +++ b/assets/stylesheets/feature-voting.scss @@ -122,3 +122,7 @@ .upgrade-answer i{ margin: 0px 5px 0px 0px; } + +.topic-post.voting-post { + button.like-count, button.toggle-like { display: none; } +} diff --git a/plugin.rb b/plugin.rb index aa64dad..b923167 100755 --- a/plugin.rb +++ b/plugin.rb @@ -15,6 +15,19 @@ Discourse.anonymous_filters.push(:votes) after_initialize do + require_dependency 'post_serializer' + class ::PostSerializer + attributes :can_vote + + def include_can_vote? + object.post_number == 1 && object.topic && object.topic.can_vote? + end + + def can_vote + true + end + end + require_dependency 'topic_view_serializer' class ::TopicViewSerializer attributes :can_vote, :vote_count, :user_voted