From a637344e3752fba860348ad26b2db291692366d9 Mon Sep 17 00:00:00 2001 From: ThibG Date: Wed, 5 Aug 2020 22:39:14 +0200 Subject: Fallback to previous, more approximative hashtag RE on older browsers (#14513) Fixes #14511 --- .../compose/containers/warning_container.js | 40 +++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/compose/containers/warning_container.js b/app/javascript/mastodon/features/compose/containers/warning_container.js index 947d20c5a..2977ef5df 100644 --- a/app/javascript/mastodon/features/compose/containers/warning_container.js +++ b/app/javascript/mastodon/features/compose/containers/warning_container.js @@ -5,22 +5,30 @@ import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; import { me } from '../../../initial_state'; -const HASHTAG_SEPARATORS = "_\\u00b7\\u200c"; -const ALPHA = '\\p{L}\\p{M}'; -const WORD = '\\p{L}\\p{M}\\p{N}\\p{Pc}'; -const APPROX_HASHTAG_RE = new RegExp( - '(?:^|[^\\/\\)\\w])#((' + - '[' + WORD + '_]' + - '[' + WORD + HASHTAG_SEPARATORS + ']*' + - '[' + ALPHA + HASHTAG_SEPARATORS + ']' + - '[' + WORD + HASHTAG_SEPARATORS +']*' + - '[' + WORD + '_]' + - ')|(' + - '[' + WORD + '_]*' + - '[' + ALPHA + ']' + - '[' + WORD + '_]*' + - '))', 'iu' -); +const buildHashtagRE = () => { + try { + const HASHTAG_SEPARATORS = "_\\u00b7\\u200c"; + const ALPHA = '\\p{L}\\p{M}'; + const WORD = '\\p{L}\\p{M}\\p{N}\\p{Pc}'; + return new RegExp( + '(?:^|[^\\/\\)\\w])#((' + + '[' + WORD + '_]' + + '[' + WORD + HASHTAG_SEPARATORS + ']*' + + '[' + ALPHA + HASHTAG_SEPARATORS + ']' + + '[' + WORD + HASHTAG_SEPARATORS +']*' + + '[' + WORD + '_]' + + ')|(' + + '[' + WORD + '_]*' + + '[' + ALPHA + ']' + + '[' + WORD + '_]*' + + '))', 'iu' + ); + } catch { + return /(?:^|[^\/\)\w])#(\w*[a-zA-Z·]\w*)/i; + } +}; + +const APPROX_HASHTAG_RE = buildHashtagRE(); const mapStateToProps = state => ({ needsLockWarning: state.getIn(['compose', 'privacy']) === 'private' && !state.getIn(['accounts', me, 'locked']), -- cgit From 4a4d08f3a078fbc6380a786145cc05f67c1f6e90 Mon Sep 17 00:00:00 2001 From: abcang Date: Fri, 7 Aug 2020 17:40:33 +0900 Subject: Fix eslint error (#14521) --- .../mastodon/features/compose/containers/warning_container.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/compose/containers/warning_container.js b/app/javascript/mastodon/features/compose/containers/warning_container.js index 2977ef5df..bf0660ea9 100644 --- a/app/javascript/mastodon/features/compose/containers/warning_container.js +++ b/app/javascript/mastodon/features/compose/containers/warning_container.js @@ -7,7 +7,7 @@ import { me } from '../../../initial_state'; const buildHashtagRE = () => { try { - const HASHTAG_SEPARATORS = "_\\u00b7\\u200c"; + const HASHTAG_SEPARATORS = '_\\u00b7\\u200c'; const ALPHA = '\\p{L}\\p{M}'; const WORD = '\\p{L}\\p{M}\\p{N}\\p{Pc}'; return new RegExp( @@ -21,7 +21,7 @@ const buildHashtagRE = () => { '[' + WORD + '_]*' + '[' + ALPHA + ']' + '[' + WORD + '_]*' + - '))', 'iu' + '))', 'iu', ); } catch { return /(?:^|[^\/\)\w])#(\w*[a-zA-Z·]\w*)/i; -- cgit From bd3420b1398c4c4ab2e2f2850b6dd6eaff0d361b Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 8 Aug 2020 17:57:56 +0200 Subject: Fix crash when failing to load emoji picker (#14525) Fixes #14523 --- .../mastodon/features/compose/components/emoji_picker_dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js index 360a7af6a..e8a36a923 100644 --- a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js @@ -315,7 +315,7 @@ class EmojiPickerDropdown extends React.PureComponent { this.setState({ loading: false }); }).catch(() => { - this.setState({ loading: false }); + this.setState({ loading: false, active: false }); }); } -- cgit