Add 100 character buffer to read more

This commit is contained in:
Josh Perez 2021-11-29 10:42:26 -05:00 committed by GitHub
parent c9678c4877
commit 29b4148889
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 22 deletions

View file

@ -25,6 +25,7 @@ export type Props = Pick<
const INITIAL_LENGTH = 800;
const INCREMENT_COUNT = 3000;
const BUFFER = 100;
function graphemeAwareSlice(
str: string,
@ -33,7 +34,7 @@ function graphemeAwareSlice(
hasReadMore: boolean;
text: string;
} {
if (str.length <= length) {
if (str.length <= length + BUFFER) {
return { text: str, hasReadMore: false };
}