mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-25 09:18:51 +01:00
Cache textWeight
This commit is contained in:
parent
50f0b38f42
commit
cea4590686
1 changed files with 16 additions and 6 deletions
|
@ -12,7 +12,13 @@ import { decodeBlurHash } from 'fast-blurhash';
|
||||||
import mem from 'mem';
|
import mem from 'mem';
|
||||||
import pThrottle from 'p-throttle';
|
import pThrottle from 'p-throttle';
|
||||||
import { memo } from 'preact/compat';
|
import { memo } from 'preact/compat';
|
||||||
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
import {
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from 'preact/hooks';
|
||||||
import { InView } from 'react-intersection-observer';
|
import { InView } from 'react-intersection-observer';
|
||||||
import { useLongPress } from 'use-long-press';
|
import { useLongPress } from 'use-long-press';
|
||||||
import useResizeObserver from 'use-resize-observer';
|
import useResizeObserver from 'use-resize-observer';
|
||||||
|
@ -286,10 +292,14 @@ function Status({
|
||||||
|
|
||||||
const unauthInteractionErrorMessage = `Sorry, your current logged-in instance can't interact with this post from another instance.`;
|
const unauthInteractionErrorMessage = `Sorry, your current logged-in instance can't interact with this post from another instance.`;
|
||||||
|
|
||||||
const textWeight = () =>
|
const textWeight = useCallback(
|
||||||
|
() =>
|
||||||
Math.max(
|
Math.max(
|
||||||
Math.round((spoilerText.length + htmlContentLength(content)) / 140) || 1,
|
Math.round((spoilerText.length + htmlContentLength(content)) / 140) ||
|
||||||
1,
|
1,
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
[spoilerText, content],
|
||||||
);
|
);
|
||||||
|
|
||||||
const createdDateText = niceDateTime(createdAtDate);
|
const createdDateText = niceDateTime(createdAtDate);
|
||||||
|
|
Loading…
Reference in a new issue