New 'presence_max_users_shown' site setting (defaults to 5)

This commit is contained in:
Régis Hanol 2018-01-29 10:48:42 +01:00
parent 8ab585e25f
commit 238e3f8a71
3 changed files with 8 additions and 4 deletions

View File

@ -1,3 +1,4 @@
en: en:
site_settings: site_settings:
presence_enabled: 'Show users that are currently replying to the current topic, or editing the current post?' presence_enabled: 'Show users that are currently replying to the current topic, or editing the current post?'
presence_max_users_shown: 'Maximum number of users shown.'

View File

@ -2,3 +2,7 @@ plugins:
presence_enabled: presence_enabled:
default: true default: true
client: true client: true
presence_max_users_showns:
default: 5
min: 1
max: 50

View File

@ -8,7 +8,7 @@ enabled_site_setting :presence_enabled
register_asset 'stylesheets/presence.scss' register_asset 'stylesheets/presence.scss'
PLUGIN_NAME ||= "discourse-presence".freeze PLUGIN_NAME ||= -"discourse-presence"
after_initialize do after_initialize do
@ -103,8 +103,7 @@ after_initialize do
requires_plugin PLUGIN_NAME requires_plugin PLUGIN_NAME
before_action :ensure_logged_in before_action :ensure_logged_in
ACTIONS ||= %w{edit reply}.each(&:freeze) ACTIONS ||= [-"edit", -"reply"].freeze
MAX_USERS ||= 20
def publish def publish
data = params.permit( data = params.permit(
@ -158,7 +157,7 @@ after_initialize do
{ {
messagebus_channel: channel, messagebus_channel: channel,
messagebus_id: MessageBus.last_id(channel), messagebus_id: MessageBus.last_id(channel),
users: users.limit(MAX_USERS).map { |u| BasicUserSerializer.new(u, root: false) } users: users.limit(SiteSetting.presence_max_users_shown).map { |u| BasicUserSerializer.new(u, root: false) }
} }
end end