FIX: make filter bindable

This commit is contained in:
Sam 2014-08-19 16:50:30 +10:00
parent 070cdbe64b
commit 2d16255185
2 changed files with 8 additions and 6 deletions
app/assets/javascripts/discourse

View file

@ -51,10 +51,10 @@ Ember.Handlebars.registerBoundHelper("boundI18n", function(property, options) {
Ember.Handlebars.registerHelper('countI18n', function(key, options) {
var view = Discourse.View.extend({
tagName: 'span',
shouldRerender: Discourse.View.renderIfChanged('count'),
shouldRerender: Discourse.View.renderIfChanged('count', 'suffix'),
render: function(buffer) {
buffer.push(I18n.t(key + (this.get('suffix') || ""), { count: this.get('count') }));
buffer.push(I18n.t(key + (this.get('suffix') || ''), { count: this.get('count') }));
}
});

View file

@ -58,18 +58,20 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
notify: function(data){
if (!this.newIncoming) { return; }
if ((this.filter === "all" ||this.filter === "latest" || this.filter === "new") && data.message_type === "new_topic" ) {
var filter = this.get("filter");
if ((filter === "all" || filter === "latest" || filter === "new") && data.message_type === "new_topic" ) {
this.addIncoming(data.topic_id);
}
if ((this.filter === "all" || this.filter === "unread") && data.message_type === "unread") {
if ((filter === "all" || filter === "unread") && data.message_type === "unread") {
var old = this.states["t" + data.topic_id];
if(!old || old.highest_post_number === old.last_read_post_number) {
this.addIncoming(data.topic_id);
}
}
if(this.filter === "latest" && data.message_type === "latest") {
if(filter === "latest" && data.message_type === "latest") {
this.addIncoming(data.topic_id);
}
@ -90,7 +92,7 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
// track how many new topics came for this filter
trackIncoming: function(filter) {
this.newIncoming = [];
this.filter = filter;
this.set("filter", filter);
this.set("incomingCount", 0);
},