Community

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
cesbrandt
Community Champion

Community Thread Layouts

Jump to solution

Is it just me, or are some threads loading with a flat layout even when the Discussion View Style is configured to load them as threaded? Is it possible to force the threaded layout back on? I've already tried toggling the view setting. Smiley Sad

Tags (2)
1 Solution

Accepted Solutions

cesbrandt, you're correct about the reply count. When discussions receive more than 100 replies, the replies "un-thread" and flip to pagination. Unfortunately, it's not something that can be controlled with a setting; it's built into the Jive software. In fact, Jive's community has a feature idea open for it!

View solution in original post

5 Replies
Stef_retired
Community Team
Community Team

Hi, cesbrandt, I'm not immediately seeing what you mean. I've just clicked on a few discussions and they look as threaded as always. Could you link to an example so we can troubleshoot?

Also, because this is a question about the Community rather than the Canvas platform, we're going to move it to the https://community.canvaslms.com/groups/community?sr=search&searchId=4f3ff775-c381-4008-832d-cc367da2...‌ which is where we discuss all-things-Community. If you're not yet a member of that group please click on the link to the group to request access.

My apologies, I've moved it.

I first noticed it in the Priority: Quizzes.Next‌, but since that's a restricted group, I found some examples in the Find Answers‌:

I think it may have something to do with the reply count. It only appears to happen in the longer threads and doesn't seem to be isolated to a particular thread type. I'm guessing it's a system setting (because I can't find one in the user settings), but I don't know anything about Jive forums from an administrative perspective. ^^'

cesbrandt, you're correct about the reply count. When discussions receive more than 100 replies, the replies "un-thread" and flip to pagination. Unfortunately, it's not something that can be controlled with a setting; it's built into the Jive software. In fact, Jive's community has a feature idea open for it!

Ugh, that is quite...disappointing. Maybe I've become spoiled since threaded threads became a streamlined thing on forum software, but it's impossible to track a long discussion without it. xD

Updated 4/27/2017 3:45 PM EST:

Fixed a bug in the recursive function for building the threads that was producing duplicate posts outside the correct thread, and added a safeguard function to prevent duplication entries.

Updated 4/25/2017 1:58 PM EST

Fixed recognition for access it via "message". I noticed this when I pulled up a thread via the notifications page. ^^'

Original:

For anyone interested, I've written an "override" userscript for this (*crazed* I must see threaded!).

Simply put, it detects if the thread is paginated and, if so, pulls all posts the same way the pagination does, but then organizes them into the threaded view.

Important Note 1: The reply count cutoff for threaded is there for a VERY good reason. By loading all replies in a threaded format, the loading time is significantly increased. The more replies, the longer it takes.

Important Note 2: This script executes in the browser what would normally be executed on the server. This means that your browser will lock up as it processes the thread replies. It also means that larger thread, whether by number of replies or the size of the content of the replies, will require more RAM to process. The larger the thread, the greater the risk of the browser crashing.

If, like me, you're more concerned about the ability to follow a thread visually than it taking 5-15 seconds longer to load, then here's the userscript I just wrote (tested in all the threads I had linked earlier as examples of the "issue" I was asking about):

// ==UserScript==
// @name          Jive Threaded/Flat View Override
// @include       /^https://community\.canvaslms\.com/message/\d+.*$/
// @include       /^https://community\.canvaslms\.com/thread/\d+.*$/
// @version       0.1
// ==/UserScript==

var $ = jQuery.noConflict();
var url = window.location.href;
var view = url.split('/')[3];
var contentID = parseInt((view == 'thread' ? url : $('link[rel=canonical]').attr('href')).match(/\.com\/thread\/\d+/i)[0].split('/')[2]);

function callAPI(start, lastPageStart, oncomplete, compiledJSON) {
     var callURL = 'https://community.canvaslms.com/replies/view.jspa?contentID=' + contentID + '&contentType=1&start=' + start + '&messageTarget=all&mode=comments';
     if(typeof compiledJSON === 'undefined') {
          compiledJSON = [];
     }
     $.when(callAJAX(callURL)).then(function(json, status, xhr) {
          compiledJSON.push(json.commentsPage);
          if(start == lastPageStart) {
               oncomplete(compiledJSON);
          } else {
               callAPI((start + 25), lastPageStart, oncomplete, compiledJSON);
          }
     });
     return;
}

function callAJAX(callURL) {
     return $.ajax({
          url: callURL
     });
}

function buildTree(input, parentID) {
     var output = [];
     for(var i = 0; i < input.length; i++) {
          var reply = $(input[i]);
          var id = reply.data('objectId');
          if(parseInt(reply.children('.jive-comment-content').children('.j-comment-footer').find('.jive-comment-action-button a').data('parentId')) == parentID) {
               var children = buildTree(input, id);
               if(children.length > 0) {
                    reply.append($('<ul />').addClass('jive-comment jive-comment-threaded clearfix jive-comment-indent-1'));
                    for(var j = 0; j < children.length; j++) {
                         reply.children('ul.jive-comment.jive-comment-threaded.clearfix.jive-comment-indent-1').append(children[j].reply);
                    }
               }
               output.push({id: id, reply: reply});
          }
     }
     return output;
}

$(function() {
     var pages = $('.j-pagination');
     if(pages.length !== 0) {
          callAPI(0, parseInt(pages.find('.j-pagination-all a.icon-last').data('start')), function(jsonResults) {
               var compiledComments = [];
               var filteredComments = [];
               for(var i = 0; i < jsonResults.length; i++) {
                    $.merge(compiledComments, $($.parseHTML(jsonResults[i])[0]).find('li.reply'));
               }
               for(i = 0; i < compiledComments.length; i++) {
                    var found = false;
                    for(var j = 0; j < filteredComments.length; j++) {
                         if($(compiledComments[i]).data('objectId') == $(filteredComments[j]).data('objectId')) {
                              found = true;
                         }
                    }
                    if(!found) {
                         filteredComments.push(compiledComments[i]);
                    }
               }
               filteredComments = buildTree(filteredComments, -1);
               var commentBlock = $('#jive-comments-block .j-comment-display-listing ul.jive-comment');
               commentBlock.removeClass('jive-comment-flat').addClass('jive-comment-threaded').empty();
               for(i = 0; i < filteredComments.length; i++) {
                    commentBlock.append(filteredComments[i].reply);
               }
          });
     }
     pages.hide();
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍