Don't hijack existing context to do this
This commit is contained in:
@@ -93,7 +93,7 @@
|
||||
this.courseSettings = options.courseSettings;
|
||||
this.hideRefineBar = options.hideRefineBar;
|
||||
this.supportsActiveThread = options.supportsActiveThread;
|
||||
this.profilePage = options.profilePage || false;
|
||||
this.hideReadState = options.hideReadState || false;
|
||||
this.displayedCollection = new Discussion(this.collection.models, {
|
||||
pages: this.collection.pages
|
||||
});
|
||||
@@ -336,24 +336,17 @@
|
||||
DiscussionThreadListView.prototype.renderThread = function(thread) {
|
||||
var threadCommentCount = thread.get('comments_count'),
|
||||
threadUnreadCommentCount = thread.get('unread_comments_count'),
|
||||
// @TODO: On the profile page, thread read state for the viewing user is not accessible via the API.
|
||||
// In this case, neverRead is set to false regardless of read state returned by the API.
|
||||
// Fix this when the Discussions API can support this query.
|
||||
neverRead = (
|
||||
!thread.get('read') &&
|
||||
threadUnreadCommentCount === threadCommentCount &&
|
||||
!this.profilePage
|
||||
),
|
||||
neverRead = !thread.get('read') && threadUnreadCommentCount === threadCommentCount,
|
||||
threadPreview = this.containsMarkup(thread.get('body')) ? '' : thread.get('body'),
|
||||
context = _.extend(
|
||||
{
|
||||
neverRead: neverRead,
|
||||
threadUrl: thread.urlFor('retrieve'),
|
||||
threadPreview: threadPreview,
|
||||
showThreadPreview: this.showThreadPreview
|
||||
showThreadPreview: this.showThreadPreview,
|
||||
hideReadState: this.hideReadState
|
||||
},
|
||||
thread.toJSON(),
|
||||
this.profilePage ? {unread_comments_count: 0} : {} // See comment above about profile page
|
||||
thread.toJSON()
|
||||
);
|
||||
return $(this.threadListItemTemplate(context).toString());
|
||||
};
|
||||
|
||||
@@ -718,16 +718,14 @@
|
||||
).toEqual(newCommentsOnUnreadThread + ' new');
|
||||
});
|
||||
|
||||
it('should display every thread as read if profilePage is passed to the constructor', function() {
|
||||
// @TODO: This is temporary, see comment in DiscussionThreadListView.prototype.renderThread
|
||||
this.view = makeView(new Discussion(this.threads), {profilePage: true});
|
||||
it('should display every thread as read if hideReadState: true is passed to the constructor', function() {
|
||||
this.view = makeView(new Discussion(this.threads), {hideReadState: true});
|
||||
this.view.render();
|
||||
expect(this.view.$('.never-read').length).toEqual(0);
|
||||
});
|
||||
|
||||
it('does not show the "x new" indicator for any thread if profilePage is passed', function() {
|
||||
// @TODO: This is temporary, see comment in DiscussionThreadListView.prototype.renderThread
|
||||
this.view = makeView(new Discussion(this.threads), {profilePage: true});
|
||||
it('does not show the "x new" indicator for any thread if hideReadState: true is passed', function() {
|
||||
this.view = makeView(new Discussion(this.threads), {hideReadState: true});
|
||||
this.view.render();
|
||||
expect(this.view.$('.forum-nav-thread-unread-comments-count').length).toEqual(0);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<li data-id="<%- id %>" class="forum-nav-thread<% if (neverRead) { %> never-read<% } %>">
|
||||
<li data-id="<%- id %>" class="forum-nav-thread<% if (!hideReadState && neverRead) { %> never-read<% } %>">
|
||||
<a href="<%- threadUrl %>" class="forum-nav-thread-link">
|
||||
<div class="forum-nav-thread-wrapper-0">
|
||||
<%
|
||||
@@ -75,7 +75,7 @@
|
||||
%>
|
||||
</span>
|
||||
|
||||
<% if (!neverRead && unread_comments_count > 0) { %>
|
||||
<% if (!hideReadState && !neverRead && unread_comments_count > 0) { %>
|
||||
<span class="forum-nav-thread-unread-comments-count">
|
||||
<%-
|
||||
StringUtils.interpolate(
|
||||
|
||||
@@ -40,9 +40,9 @@
|
||||
el: this.$('.inline-threads'),
|
||||
courseSettings: this.courseSettings,
|
||||
hideRefineBar: true, // TODO: re-enable the search/filter bar when it works correctly
|
||||
// TODO: remove. Used temporarily to disable read state on profile page. See comment in
|
||||
// discussion_thread_list_view.js / DiscussionThreadListView.prototype.renderThread
|
||||
profilePage: true
|
||||
// @TODO: On the profile page, thread read state for the viewing user is not accessible via API.
|
||||
// Fix this when the Discussions API can support this query. Until then, hide read state.
|
||||
hideReadState: true
|
||||
}).render();
|
||||
|
||||
this.discussionThreadListView.on('thread:selected', _.bind(this.navigateToThread, this));
|
||||
|
||||
Reference in New Issue
Block a user