Skip to content

Commit 2c83cf2

Browse files
committed
Switch to query-specific collection methods
This way it the purpose of the fetch calls is clearer.
1 parent 96ba647 commit 2c83cf2

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

code_comments/htdocs/code-comments.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,16 @@
2626
comparator: function(comment) {
2727
return comment.get('time');
2828
},
29-
fetchComments: function( commentsToFetch ) {
30-
var lineQuery = ( 'line' == commentsToFetch ) ? 'line__gt' : 'line',
31-
params = {
32-
data: {
33-
path: CodeComments.path || undefined,
34-
revision: CodeComments.revision,
35-
type: CodeComments.page,
36-
}
37-
};
38-
params.data[lineQuery] = 0;
39-
40-
return this.fetch( params );
29+
defaultFetchParams: {
30+
path: CodeComments.path || undefined,
31+
revision: CodeComments.revision,
32+
type: CodeComments.page
33+
},
34+
fetchTopComments: function() {
35+
return this.fetch( { data: _.extend( { line: 0 }, this.defaultFetchParams ) } );
36+
},
37+
fetchLineComments: function() {
38+
return this.fetch( { data: _.extend( { line__gt: 0 }, this.defaultFetchParams ) } );
4139
}
4240
});
4341

@@ -81,7 +79,7 @@
8179
render: function() {
8280
$(this.el).html(this.template());
8381
this.$('button').button();
84-
TopComments.fetchComments();
82+
TopComments.fetchTopComments();
8583
return this;
8684
},
8785

@@ -109,7 +107,7 @@
109107
this.viewPerLine = {};
110108
},
111109
render: function() {
112-
LineComments.fetchComments( 'line' );
110+
LineComments.fetchLineComments();
113111
},
114112
addOne: function(comment) {
115113
var line = comment.get('line');

0 commit comments

Comments
 (0)