diff options
| author | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-12-09 09:44:51 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-09 09:44:51 +0900 |
| commit | f6f79fb38826430f64e58b1a91d54be70659c338 (patch) | |
| tree | dcae6183efa91af42ae0ac6d845c792051cba6c0 /src/client | |
| parent | Refactor getTextCount (#3553) (diff) | |
| download | misskey-f6f79fb38826430f64e58b1a91d54be70659c338.tar.gz misskey-f6f79fb38826430f64e58b1a91d54be70659c338.tar.bz2 misskey-f6f79fb38826430f64e58b1a91d54be70659c338.zip | |
Refactor getChildrenCount (#3554)
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/app/common/views/components/mfm.ts | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/client/app/common/views/components/mfm.ts b/src/client/app/common/views/components/mfm.ts index 31d5d16600..a6487aa4fb 100644 --- a/src/client/app/common/views/components/mfm.ts +++ b/src/client/app/common/views/components/mfm.ts @@ -16,15 +16,8 @@ function getTextCount(tokens: Node[]): number { } function getChildrenCount(tokens: Node[]): number { - let count = 0; - const extract = (tokens: Node[]) => { - tokens.filter(x => x.children).forEach(x => { - count++; - extract(x.children); - }); - }; - extract(tokens); - return count; + const countTree = tokens.filter(x => x.children).map(x => getChildrenCount(x.children)); + return countTree.length + sum(countTree); } export default Vue.component('misskey-flavored-markdown', { |