Uploaded image for project: 'Blog Application'
  1. Blog Application
  2. BLOG-184

Likes are not correctly displayed on Cards blog post layout

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 9.11.1
    • 9.11
    • None
    • Unknown

    Description

      When testing the feature introduced by the ticket BLOG-181 I noticed that the likes are not correctly displayed on the Cards blog post layout.

      To reproduce :

      • XWiki version 12.10.6
      • Edit the Blog.WebHome page and set the Posts layout to 'Cards' and save the page

      Expected results : The likes heart and the number of likes are displayed on the blog posts

      Actual results : The likes heart are displayed but the number of likes is always null, see screenshot :  

       

      The code responsible of displaying the likes number added to the Cards blog post layout (Blog.BlogPostLayoutCards) is : 

       #if ($services.like.displayButton($pDoc))
                #set ($optLikeRecord = $services.like.getLikes($pDoc))
                #set ($likeNumber = $optLikeRecord.get().likeNumber)
                <div class="like-button btn btn-default disabled badge"
                  title="$escapetool.xml($services.localization.render('like.button.title', [$likeNumber]))">
                  $services.icon.renderHTML('heart') <span class="like-number">$likeNumber</span>
                </div>
              #elseif ($services.ratings)
       

      Note that this code #set ($optLikeRecord = $services.like.getLikes($pDoc)) returns an Optional<Long>, so the code used to get the likes number, (#set ($likeNumber = $optLikeRecord.get().likeNumber)), cannot work, see https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html.

      So, $optLikeRecord.get() is enough to get the number of likes.

      Another remark is that the code is not managing the case when the $services.like.getLikes() method returns an empty Optional instance.

      Note that the $services.like.getLikes($pDoc) method takes an EntityReference as a parameter and the $pDoc variable is an xwiki Document.

      Attachments

        Issue Links

          Activity

            People

              acotiuga Alex Cotiugă
              mouhb Mohamed Boussaa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: