Apply comments from eviltrout, using this.get('category.id'), and use snake case for category_id

This commit is contained in:
cpradio 2014-10-24 17:01:28 -04:00
parent 439f393d89
commit c6e54741bb
3 changed files with 4 additions and 5 deletions

View File

@ -85,8 +85,7 @@ var controllerOpts = {
if (selected.length > 0) {
promise = Discourse.Topic.bulkOperation(selected, operation);
} else {
var category = this.get('category');
promise = Discourse.Topic.bulkOperationByFilter('unread', operation, category ? category.id : null);
promise = Discourse.Topic.bulkOperationByFilter('unread', operation, this.get('category.id'));
}
promise.then(function(result) {
if (result && result.topic_ids) {

View File

@ -454,7 +454,7 @@ Discourse.Topic.reopenClass({
bulkOperationByFilter: function(filter, operation, categoryId) {
var data = { filter: filter, operation: operation };
if (categoryId) data['categoryId'] = categoryId;
if (categoryId) data['category_id'] = categoryId;
return Discourse.ajax("/topics/bulk", {
type: 'PUT',
data: data

View File

@ -359,8 +359,8 @@ class TopicsController < ApplicationController
topic_ids = params[:topic_ids].map {|t| t.to_i}
elsif params[:filter] == 'unread'
tq = TopicQuery.new(current_user)
if params[:categoryId]
topic_ids = TopicQuery.unread_filter(tq.joined_topic_user).listable_topics.where('category_id = ?', params[:categoryId]).pluck(:id)
if params[:category_id]
topic_ids = TopicQuery.unread_filter(tq.joined_topic_user).listable_topics.where('category_id = ?', params[:category_id]).pluck(:id)
else
topic_ids = TopicQuery.unread_filter(tq.joined_topic_user).listable_topics.pluck(:id)
end