mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-24 16:58:47 +01:00
Throttle account fetches
This commit is contained in:
parent
04e1d60e54
commit
8d91bfb0a3
1 changed files with 6 additions and 1 deletions
|
@ -11,6 +11,7 @@ import {
|
||||||
import { decodeBlurHash, getBlurHashAverageColor } from 'fast-blurhash';
|
import { decodeBlurHash, getBlurHashAverageColor } from 'fast-blurhash';
|
||||||
import { shallowEqual } from 'fast-equals';
|
import { shallowEqual } from 'fast-equals';
|
||||||
import prettify from 'html-prettify';
|
import prettify from 'html-prettify';
|
||||||
|
import pThrottle from 'p-throttle';
|
||||||
import { Fragment } from 'preact';
|
import { Fragment } from 'preact';
|
||||||
import { memo } from 'preact/compat';
|
import { memo } from 'preact/compat';
|
||||||
import {
|
import {
|
||||||
|
@ -77,10 +78,14 @@ import TranslationBlock from './translation-block';
|
||||||
const SHOW_COMMENT_COUNT_LIMIT = 280;
|
const SHOW_COMMENT_COUNT_LIMIT = 280;
|
||||||
const INLINE_TRANSLATE_LIMIT = 140;
|
const INLINE_TRANSLATE_LIMIT = 140;
|
||||||
|
|
||||||
|
const throttle = pThrottle({
|
||||||
|
limit: 1,
|
||||||
|
interval: 1000,
|
||||||
|
});
|
||||||
function fetchAccount(id, masto) {
|
function fetchAccount(id, masto) {
|
||||||
return masto.v1.accounts.$select(id).fetch();
|
return masto.v1.accounts.$select(id).fetch();
|
||||||
}
|
}
|
||||||
const memFetchAccount = pmem(fetchAccount);
|
const memFetchAccount = pmem(throttle(fetchAccount));
|
||||||
|
|
||||||
const visibilityText = {
|
const visibilityText = {
|
||||||
public: 'Public',
|
public: 'Public',
|
||||||
|
|
Loading…
Reference in a new issue