Skip to content

Commit

Permalink
Issue webcompat#1058 - Removing ternary operation, making eslint styl…
Browse files Browse the repository at this point in the history
…e changes.
  • Loading branch information
deepthivenkat committed Aug 1, 2016
1 parent 385ddad commit 2924854
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 4 additions & 2 deletions webcompat/static/js/lib/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,9 @@ issues.MainView = Backbone.View.extend({
var _id = $(location.hash);
window.scrollTo(0, _id.offset().top);
}
(response[0].lastPageNumber > 1) ? this.getRemainingComments(++response[0].lastPageNumber) : '';
if (response[0].lastPageNumber > 1) {
this.getRemainingComments(++response[0].lastPageNumber);
}
}, this)).error(function() {
var msg = 'There was an error retrieving issue comments. Please reload to try again.';
wcEvents.trigger('flash:error', {message: msg, timeout: 4000});
Expand All @@ -460,7 +462,7 @@ issues.MainView = Backbone.View.extend({

_.each(_.range(2, count), function(i) {
this.comments.fetchPage({pageNumber: i, headers: {'Accept': 'application/json'}});
},this);
}, this);
},

addComment: function(comment) {
Expand Down
11 changes: 5 additions & 6 deletions webcompat/static/js/lib/models/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ issues.Comment = Backbone.Model.extend({
createdAt: moment(response.created_at).fromNow(),
rawBody: response.body
});
var linkHeaderRegex = /(?=.*?(link|last|next|comments|page)).*/
if (linkHeaderRegex.test(jqXHR.xhr.getAllResponseHeaders())) {
response.lastPageNumber = this.parseHeader(jqXHR.xhr.getResponseHeader('Link')).last.split('\?page\=')[1];
var linkHeader = jqXHR.xhr.getResponseHeader('Link');
if (linkHeader !== null && !!this.parseHeader(linkHeader).last) {
response.lastPageNumber = this.parseHeader(linkHeader).last.split('\?page\=')[1];
}
else if(!jqXHR.xhr.getAllResponseHeaders().includes('link:')){
response.lastPageNumber = "1";
else {
response.lastPageNumber = '1';
}

},
parseHeader: function(linkHeader) {
//TODO: Abstract 'parseHeader' method from comment.js in to a mixin
Expand Down

0 comments on commit 2924854

Please sign in to comment.