work in progress, live unread and new counts

This commit is contained in:
Sam
2013-05-28 17:52:52 +10:00
parent 33683715a9
commit 73834370a5
26 changed files with 213 additions and 93 deletions

View File

@@ -179,14 +179,19 @@ class PostCreator
topic.posts_count = 1
topic_json = TopicListItemSerializer.new(topic).as_json
message = {
topic_id: topic.id,
message_type: "new_topic",
payload: {
last_read_post_number: nil,
topic_id: topic.id
}
}
group_ids = secure_group_ids(topic)
MessageBus.publish("/new", message.as_json, group_ids: group_ids)
MessageBus.publish("/latest", topic_json, group_ids: group_ids)
# If it has a category, add it to the category views too
if topic.category
MessageBus.publish("/category/#{topic.category.slug}", topic_json, group_ids: group_ids)
end
# TODO post creator should get an unread
end
def create_topic

View File

@@ -212,7 +212,12 @@ class TopicQuery
protected
def create_list(filter, list_opts={})
topics = default_list(list_opts)
opts = list_opts
if @opts[:topic_ids]
opts = opts.dup
opts[:topic_ids] = @opts[:topic_ids]
end
topics = default_list(opts)
topics = yield(topics) if block_given?
TopicList.new(filter, @user, topics)
end
@@ -248,6 +253,10 @@ class TopicQuery
result = result.where('topics.id <> ?', query_opts[:except_topic_id]) if query_opts[:except_topic_id].present?
result = result.offset(query_opts[:page].to_i * page_size) if query_opts[:page].present?
if list_opts[:topic_ids]
result = result.where('topics.id in (?)', list_opts[:topic_ids])
end
unless @user && @user.moderator?
category_ids = @user.secure_category_ids if @user
if category_ids.present?