Custom Emoji: Fix loading large quantities (#2820)
This commit is contained in:
parent
2d2ac41c6b
commit
487cde9176
@ -5,16 +5,27 @@ import { throttle } from '../util/schedulers';
|
||||
|
||||
import useLastSyncTime from './useLastSyncTime';
|
||||
|
||||
const LOAD_QUEUE = new Set<string>();
|
||||
let LOAD_QUEUE = new Set<string>();
|
||||
const RENDER_HISTORY = new Set<string>();
|
||||
const THROTTLE = 200;
|
||||
const LIMIT_PER_REQUEST = 100;
|
||||
|
||||
const loadFromQueue = throttle(() => {
|
||||
const queue = [...LOAD_QUEUE];
|
||||
|
||||
const queueToLoad = queue.slice(0, LIMIT_PER_REQUEST);
|
||||
const otherQueue = queue.slice(LIMIT_PER_REQUEST + 1);
|
||||
|
||||
getActions().loadCustomEmojis({
|
||||
ids: [...LOAD_QUEUE],
|
||||
ids: queueToLoad,
|
||||
});
|
||||
|
||||
LOAD_QUEUE.clear();
|
||||
LOAD_QUEUE = new Set(otherQueue);
|
||||
|
||||
// Schedule next load
|
||||
if (LOAD_QUEUE.size) {
|
||||
loadFromQueue();
|
||||
}
|
||||
}, THROTTLE, false);
|
||||
|
||||
const updateLastRendered = throttle(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user