slightly refactor compose box (#192)

This commit is contained in:
Nolan Lawson 2018-04-20 10:36:05 -07:00 committed by GitHub
parent 581a0fcd00
commit 64973757a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -153,20 +153,16 @@
}, },
store: () => store, store: () => store,
computed: { computed: {
computedClassName: (overLimit, realm, size, postPrivacyKey, isReply) => { computedClassName: (overLimit, realm, size, postPrivacyKey, isReply) => (classname(
return classname(
'compose-box', 'compose-box',
overLimit && 'over-char-limit', overLimit && 'over-char-limit',
size === 'slim' && 'slim-size', size === 'slim' && 'slim-size',
isReply && postPrivacyKey === 'direct' && 'direct-reply' isReply && postPrivacyKey === 'direct' && 'direct-reply'
) )),
}, hideAndFadeIn: (hidden) => (classname(
hideAndFadeIn: (hidden) => {
return classname(
'compose-box-fade-in', 'compose-box-fade-in',
hidden && 'hidden' hidden && 'hidden'
) )),
},
composeData: ($currentComposeData, realm) => $currentComposeData[realm] || {}, composeData: ($currentComposeData, realm) => $currentComposeData[realm] || {},
text: (composeData) => composeData.text || '', text: (composeData) => composeData.text || '',
media: (composeData) => composeData.media || [], media: (composeData) => composeData.media || [],
@ -175,9 +171,9 @@
postPrivacyKey: (composeData, defaultPostPrivacyKey) => composeData.postPrivacy || defaultPostPrivacyKey, postPrivacyKey: (composeData, defaultPostPrivacyKey) => composeData.postPrivacy || defaultPostPrivacyKey,
textLength: (text) => measureText(text), textLength: (text) => measureText(text),
contentWarningLength: (contentWarning) => measureText(contentWarning), contentWarningLength: (contentWarning) => measureText(contentWarning),
length: (textLength, contentWarningLength, contentWarningShown) => { length: (textLength, contentWarningLength, contentWarningShown) => (
return textLength + (contentWarningShown ? contentWarningLength : 0) textLength + (contentWarningShown ? contentWarningLength : 0)
}, ),
overLimit: (length) => length > CHAR_LIMIT, overLimit: (length) => length > CHAR_LIMIT,
contentWarningShown: (composeData) => composeData.contentWarningShown, contentWarningShown: (composeData) => composeData.contentWarningShown,
contentWarning: (composeData) => composeData.contentWarning || '', contentWarning: (composeData) => composeData.contentWarning || '',