mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 10:05:33 +08:00
UX: Make PresenceChannel changes more responsive (#14733)
For very fast-paced things (e.g. replying... indicators), 5s resolution is not great. This commit improves the resolution to 1 update per second.
This commit is contained in:
parent
d067ee1c5a
commit
e073451eae
@ -18,7 +18,7 @@ import User from "discourse/models/user";
|
||||
|
||||
const PRESENCE_INTERVAL_S = 30;
|
||||
const PRESENCE_DEBOUNCE_MS = isTesting() ? 0 : 500;
|
||||
const PRESENCE_THROTTLE_MS = isTesting() ? 0 : 5000;
|
||||
const PRESENCE_THROTTLE_MS = isTesting() ? 0 : 1000;
|
||||
|
||||
const PRESENCE_GET_RETRY_MS = 5000;
|
||||
|
||||
|
@ -39,8 +39,9 @@ class PresenceController < ApplicationController
|
||||
client_id = params[:client_id]
|
||||
raise Discourse::InvalidParameters.new(:client_id) if !client_id.is_a?(String) || client_id.blank?
|
||||
|
||||
# JS client is designed to throttle to one request every 5 seconds
|
||||
RateLimiter.new(nil, "update-presence-#{current_user.id}-#{client_id}}", 3, 10.seconds).performed!
|
||||
# JS client is designed to throttle to one request per second
|
||||
# When no changes are being made, it makes one request every 30 seconds
|
||||
RateLimiter.new(nil, "update-presence-#{current_user.id}", 20, 10.seconds).performed!
|
||||
|
||||
present_channels = params[:present_channels]
|
||||
if present_channels && !(present_channels.is_a?(Array) && present_channels.all? { |c| c.is_a? String })
|
||||
|
Loading…
x
Reference in New Issue
Block a user