mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
work in progress, live unread and new counts
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user