Skip to content

Commit

Permalink
Issue #387 - Don't request all labels unless logged in.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Taylor committed Nov 13, 2014
1 parent e6bb808 commit 77731f3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions webcompat/static/js/lib/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ issues.AllLabels = Backbone.Model.extend({
});

issues.LabelsView = Backbone.View.extend({
_isLoggedIn: $('body').data('username'),
el: $('.Label-wrapper'),
editorButton: null,
events: {
Expand Down Expand Up @@ -45,19 +46,20 @@ issues.LabelsView = Backbone.View.extend({
this.$el.html(this.template(this.model.toJSON()));
},
fetchLabels: function() {
var self = this;
var headersBag = {headers: {'Accept': 'application/json'}};
this.editorButton = $('.LabelEditor-launcher');
this.allLabels = new issues.AllLabels();
this.labelEditor = new issues.LabelEditorView({
model: this.allLabels,
issueView: this,
});
this.allLabels.fetch(headersBag).success(function(){
self.issueLabels = _.bind(self.getIssueLabels, self);
self.repoLabels = _.pluck(self.labelEditor.model.get('labels'), 'name');
self.editorButton.show();
});
if (this._isLoggedIn) {
this.allLabels.fetch(headersBag).success(_.bind(function(){
this.issueLabels = this.getIssueLabels();
this.repoLabels = _.pluck(this.labelEditor.model.get('labels'), 'name');
this.editorButton.show();
}, this));
}
},
getIssueLabels: function() {
return _.pluck(this.model.get('labels'), 'name');
Expand Down

0 comments on commit 77731f3

Please sign in to comment.