FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix closed comment caching by using correct property · devhttps/frontend@b2f806b · GitHub

Commit b2f806b

Browse files
committed
Fix closed comment caching by using correct property
1 parent e981db6 commit b2f806b

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎discussion/app/controllers/CommentsController.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class CommentsController(val discussionApi: DiscussionApiLike, csrfCheck: CSRFCh
164164
// caches "closed" comment threads for an hour.
165165
// if the thread is switched on again the url changes and it cache busts itself.
166166
private def cacheTime(request: RequestHeader) = {
167-
val commentsClosed = request.getParameter("commentable").contains("false")
167+
val commentsClosed = request.getParameter("commentsClosed").contains("true")
168168
if (commentsClosed && LongCacheCommentsSwitch.isSwitchedOn) CacheTime(3800) else CacheTime(60)
169169
}
170170
}

‎static/src/javascripts-legacy/projects/common/modules/discussion/comments.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Comments.prototype.fetchComments = function(options) {
163163
orderBy: orderBy,
164164
pageSize: options.pagesize || this.options.pagesize,
165165
displayThreaded: this.options.threading !== 'unthreaded',
166-
commentable: config.page.commentable
166+
commentsClosed: options.commentsClosed
167167
};
168168

169169
if (options.page) {
@@ -182,7 +182,8 @@ Comments.prototype.fetchComments = function(options) {
182182
discussionId: this.options.discussionId,
183183
orderBy: queryParams.orderBy,
184184
displayThreaded: queryParams.displayThreaded,
185-
maxResponses: queryParams.maxResponses
185+
maxResponses: queryParams.maxResponses,
186+
commentsClosed: queryParams.commentsClosed
186187
})
187188
.loadAllComments()
188189
.catch(function() {

‎static/src/javascripts-legacy/projects/common/modules/discussion/loader.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Loader.prototype.initTopComments = function() {
6969
this.gotoComment(commentId);
7070
});
7171

72-
return fetchJson('/discussion/top-comments/' + this.getDiscussionId() + '.json?commentable=' + config.page.commentable, {
72+
return fetchJson('/discussion/top-comments/' + this.getDiscussionId() + '.json?commentsClosed=' + this.getDiscussionClosed(), {
7373
mode: 'cors'
7474
}).then(
7575
function render(resp) {
@@ -446,6 +446,9 @@ Loader.prototype.loadComments = function(options) {
446446
if (options && options.shouldTruncate && this.comments.isAllPageSizeActive()) {
447447
options.pageSize = 10;
448448
}
449+
450+
// Closed state of comments is passed so we bust cache of comment thread when it is reopened
451+
options.commentsClosed = this.getDiscussionClosed();
449452

450453
return this.comments.fetchComments(options)
451454
.then(function(){

‎static/src/javascripts-legacy/projects/common/modules/discussion/whole-discussion.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ define([
6262
this.params = {
6363
orderBy: options.orderBy,
6464
displayThreaded: options.displayThreaded,
65-
maxResponses: options.maxResponses
65+
maxResponses: options.maxResponses,
66+
commentsClosed: options.commentsClosed
6667
};
6768
}
6869

@@ -105,7 +106,8 @@ define([
105106
orderBy: 'oldest',
106107
page: pageNumber,
107108
pageSize: commentsPerPage,
108-
displayThreaded: this.params.displayThreaded
109+
displayThreaded: this.params.displayThreaded,
110+
commentsClosed: this.params.commentsClosed
109111
};
110112

111113
if (this.params.maxResponses) {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL