diff options
author | pluralcafe-docker <docker@plural.cafe> | 2018-08-30 05:23:58 +0000 |
---|---|---|
committer | pluralcafe-docker <docker@plural.cafe> | 2018-08-30 05:23:58 +0000 |
commit | cc7437e25597e24b9a5f06f7991861506d9abe5c (patch) | |
tree | e627d32df29ef7ae30a67607caf3ecdc1ae333a9 /app/javascript/flavours/glitch/features | |
parent | 395164add468b1079669699dfe8eeaab73f69c15 (diff) | |
parent | 5ce67276691c37baad149f2f89f765543f70e6f9 (diff) |
Merge branch 'glitch'
Diffstat (limited to 'app/javascript/flavours/glitch/features')
9 files changed, 67 insertions, 42 deletions
diff --git a/app/javascript/flavours/glitch/features/account/components/header.js b/app/javascript/flavours/glitch/features/account/components/header.js index 174df0cc9..eda0d637e 100644 --- a/app/javascript/flavours/glitch/features/account/components/header.js +++ b/app/javascript/flavours/glitch/features/account/components/header.js @@ -56,7 +56,9 @@ export default class Header extends ImmutablePureComponent { } if (me !== account.get('id')) { - if (account.getIn(['relationship', 'requested'])) { + if (!account.get('relationship')) { // Wait until the relationship is loaded + actionBtn = ''; + } else if (account.getIn(['relationship', 'requested'])) { actionBtn = ( <div className='account--action-button'> <IconButton size={26} active icon='hourglass' title={intl.formatMessage(messages.requested)} onClick={this.props.onFollow} /> diff --git a/app/javascript/flavours/glitch/features/composer/index.js b/app/javascript/flavours/glitch/features/composer/index.js index f312e9d59..cf6f45b34 100644 --- a/app/javascript/flavours/glitch/features/composer/index.js +++ b/app/javascript/flavours/glitch/features/composer/index.js @@ -51,6 +51,7 @@ import { privacyPreference } from 'flavours/glitch/util/privacy_preference'; // State mapping. function mapStateToProps (state) { + const spoilersAlwaysOn = state.getIn(['local_settings', 'always_show_spoilers_field']); const inReplyTo = state.getIn(['compose', 'in_reply_to']); const replyPrivacy = inReplyTo ? state.getIn(['statuses', inReplyTo, 'visibility']) : null; const sideArmBasePrivacy = state.getIn(['local_settings', 'side_arm']); @@ -85,12 +86,13 @@ function mapStateToProps (state) { sideArm: sideArmPrivacy, sensitive: state.getIn(['compose', 'sensitive']), showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']), - spoiler: state.getIn(['compose', 'spoiler']), + spoiler: spoilersAlwaysOn || state.getIn(['compose', 'spoiler']), spoilerText: state.getIn(['compose', 'spoiler_text']), suggestionToken: state.getIn(['compose', 'suggestion_token']), suggestions: state.getIn(['compose', 'suggestions']), text: state.getIn(['compose', 'text']), anyMedia: state.getIn(['compose', 'media_attachments']).size > 0, + spoilersAlwaysOn: spoilersAlwaysOn, }; }; @@ -376,6 +378,7 @@ class Composer extends React.Component { spoilerText, suggestions, text, + spoilersAlwaysOn, } = this.props; let disabledButton = isSubmitting || isUploading || (!!text.length && !text.trim().length && !anyMedia); @@ -443,7 +446,7 @@ class Composer extends React.Component { onDoodleOpen={onOpenDoodleModal} onModalClose={onCloseModal} onModalOpen={onOpenActionsModal} - onToggleSpoiler={onChangeSpoilerness} + onToggleSpoiler={spoilersAlwaysOn ? null : onChangeSpoilerness} onUpload={onUpload} privacy={privacy} resetFileKey={resetFileKey} @@ -515,6 +518,7 @@ Composer.propTypes = { onUnmount: PropTypes.func, onUpload: PropTypes.func, anyMedia: PropTypes.bool, + spoilersAlwaysOn: PropTypes.bool, }; // Connecting and export. diff --git a/app/javascript/flavours/glitch/features/composer/options/index.js b/app/javascript/flavours/glitch/features/composer/options/index.js index c129622bc..05cbe24c9 100644 --- a/app/javascript/flavours/glitch/features/composer/options/index.js +++ b/app/javascript/flavours/glitch/features/composer/options/index.js @@ -285,13 +285,15 @@ export default class ComposerOptions extends React.PureComponent { title={intl.formatMessage(messages.change_privacy)} value={privacy} /> - <TextIconButton - active={spoiler} - ariaControls='glitch.composer.spoiler.input' - label='CW' - onClick={onToggleSpoiler} - title={intl.formatMessage(messages.spoiler)} - /> + {onToggleSpoiler && ( + <TextIconButton + active={spoiler} + ariaControls='glitch.composer.spoiler.input' + label='CW' + onClick={onToggleSpoiler} + title={intl.formatMessage(messages.spoiler)} + /> + )} <Dropdown active={advancedOptions && advancedOptions.some(value => !!value)} disabled={disabled} diff --git a/app/javascript/flavours/glitch/features/composer/textarea/index.js b/app/javascript/flavours/glitch/features/composer/textarea/index.js index 51d44a83b..50e46fc78 100644 --- a/app/javascript/flavours/glitch/features/composer/textarea/index.js +++ b/app/javascript/flavours/glitch/features/composer/textarea/index.js @@ -58,7 +58,7 @@ const handlers = { const right = value.slice(selectionStart).search(/[\s\u200B]/); const token = function () { switch (true) { - case left < 0 || !/[@:]/.test(value[left]): + case left < 0 || !/[@:#]/.test(value[left]): return null; case right < 0: return value.slice(left); diff --git a/app/javascript/flavours/glitch/features/composer/textarea/suggestions/item/index.js b/app/javascript/flavours/glitch/features/composer/textarea/suggestions/item/index.js index f55640bcf..331692398 100644 --- a/app/javascript/flavours/glitch/features/composer/textarea/suggestions/item/index.js +++ b/app/javascript/flavours/glitch/features/composer/textarea/suggestions/item/index.js @@ -57,6 +57,42 @@ export default class ComposerTextareaSuggestionsItem extends React.Component { } = this.props; const computedClass = classNames('composer--textarea--suggestions--item', { selected }); + // If the suggestion is an object, then we render an emoji. + // Otherwise, we render a hashtag if it starts with #, or an account. + let inner; + if (typeof suggestion === 'object') { + let url; + if (suggestion.custom) { + url = suggestion.imageUrl; + } else { + const mapping = unicodeMapping[suggestion.native] || unicodeMapping[suggestion.native.replace(/\uFE0F$/, '')]; + if (mapping) { + url = `${assetHost}/emoji/${mapping.filename}.svg`; + } + } + if (url) { + inner = ( + <div className='emoji'> + <img + alt={suggestion.native || suggestion.colons} + className='emojione' + src={url} + /> + {suggestion.colons} + </div> + ); + } + } else if (suggestion[0] === '#') { + inner = suggestion; + } else { + inner = ( + <AccountContainer + id={suggestion} + small + /> + ); + } + // The result. return ( <div @@ -66,37 +102,7 @@ export default class ComposerTextareaSuggestionsItem extends React.Component { role='button' tabIndex='0' > - { // If the suggestion is an object, then we render an emoji. - // Otherwise, we render an account. - typeof suggestion === 'object' ? function () { - const url = function () { - if (suggestion.custom) { - return suggestion.imageUrl; - } else { - const mapping = unicodeMapping[suggestion.native] || unicodeMapping[suggestion.native.replace(/\uFE0F$/, '')]; - if (!mapping) { - return null; - } - return `${assetHost}/emoji/${mapping.filename}.svg`; - } - }(); - return url ? ( - <div className='emoji'> - <img - alt={suggestion.native || suggestion.colons} - className='emojione' - src={url} - /> - {suggestion.colons} - </div> - ) : null; - }() : ( - <AccountContainer - id={suggestion} - small - /> - ) - } + { inner } </div> ); } diff --git a/app/javascript/flavours/glitch/features/local_settings/page/index.js b/app/javascript/flavours/glitch/features/local_settings/page/index.js index f88e23c47..ad5c11979 100644 --- a/app/javascript/flavours/glitch/features/local_settings/page/index.js +++ b/app/javascript/flavours/glitch/features/local_settings/page/index.js @@ -77,6 +77,14 @@ export default class LocalSettingsPage extends React.PureComponent { <h2><FormattedMessage id='settings.compose_box_opts' defaultMessage='Compose box options' /></h2> <LocalSettingsPageItem settings={settings} + item={['always_show_spoilers_field']} + id='mastodon-settings--always_show_spoilers_field' + onChange={onChange} + > + <FormattedMessage id='settings.always_show_spoilers_field' defaultMessage='Always enable the Content Warning field' /> + </LocalSettingsPageItem> + <LocalSettingsPageItem + settings={settings} item={['side_arm']} id='mastodon-settings--side_arm' options={[ diff --git a/app/javascript/flavours/glitch/features/report/components/status_check_box.js b/app/javascript/flavours/glitch/features/report/components/status_check_box.js index a685132b0..d674eecf9 100644 --- a/app/javascript/flavours/glitch/features/report/components/status_check_box.js +++ b/app/javascript/flavours/glitch/features/report/components/status_check_box.js @@ -36,6 +36,7 @@ export default class StatusCheckBox extends React.PureComponent { <Component preview={video.get('preview_url')} src={video.get('url')} + alt={video.get('description')} width={239} height={110} inline diff --git a/app/javascript/flavours/glitch/features/status/components/detailed_status.js b/app/javascript/flavours/glitch/features/status/components/detailed_status.js index 5cfc9dfae..ee9eb02c6 100644 --- a/app/javascript/flavours/glitch/features/status/components/detailed_status.js +++ b/app/javascript/flavours/glitch/features/status/components/detailed_status.js @@ -60,6 +60,7 @@ export default class DetailedStatus extends ImmutablePureComponent { <Video preview={video.get('preview_url')} src={video.get('url')} + alt={video.get('description')} inline sensitive={status.get('sensitive')} letterbox={settings.getIn(['media', 'letterbox'])} diff --git a/app/javascript/flavours/glitch/features/video/index.js b/app/javascript/flavours/glitch/features/video/index.js index a578df026..7e284a0bc 100644 --- a/app/javascript/flavours/glitch/features/video/index.js +++ b/app/javascript/flavours/glitch/features/video/index.js @@ -323,6 +323,7 @@ export default class Video extends React.PureComponent { role='button' tabIndex='0' aria-label={alt} + title={alt} width={width} height={height} onClick={this.togglePlay} |