diff --git a/app/assets/javascripts/discourse/templates/list/action-list.raw.hbs b/app/assets/javascripts/discourse/templates/list/action-list.raw.hbs new file mode 100644 index 00000000000..a859ec7e397 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/list/action-list.raw.hbs @@ -0,0 +1,8 @@ +{{#if postNumbers}} +
+ + {{#each postNumber in postNumbers}} + #{{postNumber}} + {{/each}} +
+{{/if}} diff --git a/app/assets/javascripts/discourse/templates/list/topic_list_item.raw.hbs b/app/assets/javascripts/discourse/templates/list/topic_list_item.raw.hbs index fb2f023a264..4ac4f7c0dae 100644 --- a/app/assets/javascripts/discourse/templates/list/topic_list_item.raw.hbs +++ b/app/assets/javascripts/discourse/templates/list/topic_list_item.raw.hbs @@ -9,19 +9,11 @@ {{#if controller.showTopicPostBadges}} {{raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl}} {{/if}} - {{#if expandPinned}} {{raw "list/topic-excerpt" topic=topic}} {{/if}} - - {{#if topic.bookmarked_post_numbers}} -
- - {{#each postNumber in topic.bookmarked_post_numbers}} - #{{postNumber}} - {{/each}} -
- {{/if}} + {{raw "list/action-list" topic=topic postNumbers=topic.bookmarked_post_numbers className="bookmarks" icon="bookmark"}} + {{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}} {{#unless controller.hideCategory}} diff --git a/app/assets/stylesheets/desktop/topic-list.scss b/app/assets/stylesheets/desktop/topic-list.scss index 4568af83eb0..449d9ddde73 100644 --- a/app/assets/stylesheets/desktop/topic-list.scss +++ b/app/assets/stylesheets/desktop/topic-list.scss @@ -143,6 +143,24 @@ .posts { width: 65px; } + + .post-actions { + clear: both; + width: auto; + color: scale-color($primary, $lightness: 50%); + text-align: left; + font-size: 12px; + margin-top: 5px; + .fa { + margin-right: 2px; + } + a { + font-size: 11px; + color: scale-color($primary, $lightness: 50%); + margin-right: 3px; + line-height: 20px; + } + } .activity { width: 60px; &:lang(zh_CN) { diff --git a/app/serializers/topic_list_item_serializer.rb b/app/serializers/topic_list_item_serializer.rb index dd0f66be00c..a9f961827ef 100644 --- a/app/serializers/topic_list_item_serializer.rb +++ b/app/serializers/topic_list_item_serializer.rb @@ -8,7 +8,8 @@ class TopicListItemSerializer < ListableTopicSerializer :category_id, :op_like_count, :pinned_globally, - :bookmarked_post_numbers + :bookmarked_post_numbers, + :liked_post_numbers has_many :posters, serializer: TopicPosterSerializer, embed: :objects has_many :participants, serializer: TopicPosterSerializer, embed: :objects @@ -30,9 +31,21 @@ class TopicListItemSerializer < ListableTopicSerializer end def include_bookmarked_post_numbers? + include_post_action? :bookmark + end + + def include_liked_post_numbers? + include_post_action? :like + end + + def include_post_action?(action) object.user_data && object.user_data.post_action_data && - object.user_data.post_action_data.key?(PostActionType.types[:bookmark]) + object.user_data.post_action_data.key?(PostActionType.types[action]) + end + + def liked_post_numbers + object.user_data.post_action_data[PostActionType.types[:like]] end def bookmarked_post_numbers