From 06a0dc68a991abafbeb2f344e6f781de279cce9c Mon Sep 17 00:00:00 2001 From: Thorsten Claus Date: Sat, 27 Feb 2021 10:46:43 +0100 Subject: [PATCH] Enabled likes-on-comments in mobile view --- .../javascripts/mobile/mobile_post_actions.js | 4 ++-- app/assets/stylesheets/comments.scss | 2 +- app/assets/stylesheets/mobile/comments.scss | 9 +++++++++ app/helpers/mobile_helper.rb | 15 +++++++++++++++ app/views/comments/_comment.mobile.haml | 3 +++ 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/mobile/mobile_post_actions.js b/app/assets/javascripts/mobile/mobile_post_actions.js index 76f1126d5..75946eff5 100644 --- a/app/assets/javascripts/mobile/mobile_post_actions.js +++ b/app/assets/javascripts/mobile/mobile_post_actions.js @@ -75,8 +75,8 @@ onLike: function(evt){ evt.preventDefault(); - var link = $(evt.target).closest(".like-action"), - likeCounter = $(evt.target).closest(".stream-element").find(".like-count"); + var link = $(evt.target).closest(".like-action").first(), + likeCounter = $(evt.target).find(".like-count").first(); if(!link.hasClass("loading") && link.hasClass("inactive")) { Diaspora.Mobile.PostActions.like(likeCounter, link); diff --git a/app/assets/stylesheets/comments.scss b/app/assets/stylesheets/comments.scss index efabb44e4..bcfa8ab8e 100644 --- a/app/assets/stylesheets/comments.scss +++ b/app/assets/stylesheets/comments.scss @@ -24,7 +24,7 @@ .comments > .comment, .comment.new-comment-form-wrapper { - + margin: 0; border-top: 1px dotted $border-grey; padding: 10px 0; diff --git a/app/assets/stylesheets/mobile/comments.scss b/app/assets/stylesheets/mobile/comments.scss index 62db27354..9760492f5 100644 --- a/app/assets/stylesheets/mobile/comments.scss +++ b/app/assets/stylesheets/mobile/comments.scss @@ -71,12 +71,21 @@ .entypo-heart.active { color: $red; } } + .comment-stats { + @extend .post-stats; + bottom: 25px; + } + .post-action { display: flex; margin: 0 7px; .disabled { color: $medium-gray; } } + + .comment-action { + @extend .post-action; + } .add-comment-switcher { padding-top: 10px; } diff --git a/app/helpers/mobile_helper.rb b/app/helpers/mobile_helper.rb index bdc92d7e6..5be8d0d1e 100644 --- a/app/helpers/mobile_helper.rb +++ b/app/helpers/mobile_helper.rb @@ -39,6 +39,21 @@ module MobileHelper end end + def mobile_like_comment_icon(comment) + puts "Mobile like on comment!" + if current_user && current_user.liked?(comment) + link_to content_tag(:span, comment.likes.size, class: "count like-count"), + "#", + data: {url: comment_like_path(comment.id, current_user.like_for(comment).id)}, + class: "entypo-heart like-action active" + else + link_to content_tag(:span, comment.likes.size, class: "count like-count"), + "#", + data: {url: comment_likes_path(comment.id)}, + class: "entypo-heart like-action inactive" + end + end + def mobile_comment_icon(post) link_to content_tag(:span, post.comments.size, class: "count comment-count"), new_post_comment_path(post), diff --git a/app/views/comments/_comment.mobile.haml b/app/views/comments/_comment.mobile.haml index 8664c7413..aa8c0a2ea 100644 --- a/app/views/comments/_comment.mobile.haml +++ b/app/views/comments/_comment.mobile.haml @@ -21,3 +21,6 @@ %div{class: direction_for(comment.text)} = comment.message.markdownified + .comment-stats + .comment-action + = mobile_like_comment_icon(comment)