summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/app/common/views/components/mfm.ts12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/client/app/common/views/components/mfm.ts b/src/client/app/common/views/components/mfm.ts
index ecb22b6bc4..31d5d16600 100644
--- a/src/client/app/common/views/components/mfm.ts
+++ b/src/client/app/common/views/components/mfm.ts
@@ -10,15 +10,9 @@ import { toUnicode } from 'punycode';
import syntaxHighlight from '../../../../../mfm/syntax-highlight';
function getTextCount(tokens: Node[]): number {
- let count = 0;
- const extract = (tokens: Node[]) => {
- count += sum(tokens.filter(x => x.name === 'text').map(x => length(x.props.text)));
- tokens.filter(x => x.children).forEach(x => {
- extract(x.children);
- });
- };
- extract(tokens);
- return count;
+ const rootCount = sum(tokens.filter(x => x.name === 'text').map(x => length(x.props.text)));
+ const childrenCount = sum(tokens.filter(x => x.children).map(x => getTextCount(x.children)));
+ return rootCount + childrenCount;
}
function getChildrenCount(tokens: Node[]): number {