diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-11-22 01:51:26 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-11-22 01:51:26 +0900 |
| commit | 67df681a48935e83669ae6522a35e5ccc4005f60 (patch) | |
| tree | eef4a3a71531bf4d8a7a8129a3c74903eda53069 /src/client/app | |
| parent | Feature / user recommendation config in admin ui (#3357) (diff) | |
| download | misskey-67df681a48935e83669ae6522a35e5ccc4005f60.tar.gz misskey-67df681a48935e83669ae6522a35e5ccc4005f60.tar.bz2 misskey-67df681a48935e83669ae6522a35e5ccc4005f60.zip | |
Refactoring
Diffstat (limited to 'src/client/app')
| -rw-r--r-- | src/client/app/common/views/components/mfm.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/client/app/common/views/components/mfm.ts b/src/client/app/common/views/components/mfm.ts index b7ff5bd487..e93ea5ccba 100644 --- a/src/client/app/common/views/components/mfm.ts +++ b/src/client/app/common/views/components/mfm.ts @@ -9,18 +9,18 @@ import MkGoogle from './google.vue'; import { toUnicode } from 'punycode'; import syntaxHighlight from '../../../../../mfm/syntax-highlight'; -function getText(tokens: Node[]): string { - let text = ''; +function getTextCount(tokens: Node[]): number { + let count = 0; const extract = (tokens: Node[]) => { tokens.filter(x => x.name === 'text').forEach(x => { - text += x.props.text; + count += length(x.props.text); }); tokens.filter(x => x.children).forEach(x => { extract(x.children); }); }; extract(tokens); - return text; + return count; } function getChildrenCount(tokens: Node[]): number { @@ -98,7 +98,7 @@ export default Vue.component('misskey-flavored-markdown', { case 'big': { bigCount++; - const isLong = length(getText(token.children)) > 10 || getChildrenCount(token.children) > 5; + const isLong = getTextCount(token.children) > 10 || getChildrenCount(token.children) > 5; const isMany = bigCount > 3; return (createElement as any)('strong', { attrs: { @@ -113,7 +113,7 @@ export default Vue.component('misskey-flavored-markdown', { case 'motion': { motionCount++; - const isLong = length(getText(token.children)) > 10 || getChildrenCount(token.children) > 5; + const isLong = getTextCount(token.children) > 10 || getChildrenCount(token.children) > 5; const isMany = motionCount > 3; return (createElement as any)('span', { attrs: { |