From 70c308c4aa97acaaf6354420bee7d843ddf97d13 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 31 Aug 2018 13:31:45 +0200 Subject: [Glitch] When search enabled, display hint in search popout Port 7901f9f63e156732ab10154c34f3c2d188471a9d to glitch-soc --- app/javascript/flavours/glitch/util/initial_state.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/javascript/flavours/glitch/util') diff --git a/app/javascript/flavours/glitch/util/initial_state.js b/app/javascript/flavours/glitch/util/initial_state.js index 2c4ab9091..236ea1c3a 100644 --- a/app/javascript/flavours/glitch/util/initial_state.js +++ b/app/javascript/flavours/glitch/util/initial_state.js @@ -19,6 +19,7 @@ export const boostModal = getMeta('boost_modal'); export const favouriteModal = getMeta('favourite_modal'); export const deleteModal = getMeta('delete_modal'); export const me = getMeta('me'); +export const searchEnabled = getMeta('search_enabled'); export const maxChars = (initialState && initialState.max_toot_chars) || 500; export default initialState; -- cgit From c6942a528332e99b605efa95ffa1c710324d368c Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 28 Aug 2018 17:16:30 +0200 Subject: Add option to not automatically unfold content warnings matching a regexp Fixes #678 --- app/javascript/flavours/glitch/components/status.js | 14 +++++++++++++- .../glitch/features/local_settings/page/index.js | 13 ++++++++++++- .../flavours/glitch/features/status/index.js | 8 +++++++- .../flavours/glitch/reducers/local_settings.js | 1 + .../flavours/glitch/util/content_warning.js | 19 +++++++++++++++++++ 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 app/javascript/flavours/glitch/util/content_warning.js (limited to 'app/javascript/flavours/glitch/util') diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index e0d591ff6..9f47abfef 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -13,6 +13,7 @@ import { MediaGallery, Video } from 'flavours/glitch/util/async-components'; import { HotKeys } from 'react-hotkeys'; import NotificationOverlayContainer from 'flavours/glitch/features/notifications/containers/overlay_container'; import classNames from 'classnames'; +import { autoUnfoldCW } from 'flavours/glitch/util/content_warning'; // We use the component (and not the container) since we do not want // to use the progress bar to show download progress @@ -56,7 +57,7 @@ export default class Status extends ImmutablePureComponent { state = { isCollapsed: false, autoCollapsed: false, - isExpanded: this.props.settings.getIn(['content_warnings', 'auto_unfold']), + isExpanded: undefined, } // Avoid checking props that are functions (and whose equality will always @@ -124,6 +125,17 @@ export default class Status extends ImmutablePureComponent { updated = true; } + if (nextProps.expanded === undefined && + prevState.isExpanded === undefined && + update.isExpanded === undefined + ) { + const isExpanded = autoUnfoldCW(nextProps.settings, nextProps.status); + if (isExpanded !== undefined) { + update.isExpanded = isExpanded; + updated = true; + } + } + return updated ? update : null; } 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 37396d970..0db49ba5d 100644 --- a/app/javascript/flavours/glitch/features/local_settings/page/index.js +++ b/app/javascript/flavours/glitch/features/local_settings/page/index.js @@ -17,6 +17,7 @@ const messages = defineMessages({ side_arm_keep: { id: 'settings.side_arm_reply_mode.keep', defaultMessage: 'Keep secondary toot button to set privacy' }, side_arm_copy: { id: 'settings.side_arm_reply_mode.copy', defaultMessage: 'Copy privacy setting of the toot being replied to' }, side_arm_restrict: { id: 'settings.side_arm_reply_mode.restrict', defaultMessage: 'Restrict privacy setting to that of the toot being replied to' }, + regexp: { id: 'settings.content_warnings.regexp', defaultMessage: 'Regular expression' }, }); @injectIntl @@ -122,7 +123,7 @@ export default class LocalSettingsPage extends React.PureComponent { ), - ({ onChange, settings }) => ( + ({ intl, onChange, settings }) => (

+ + +
), ({ onChange, settings }) => ( diff --git a/app/javascript/flavours/glitch/features/status/index.js b/app/javascript/flavours/glitch/features/status/index.js index 060f2f345..3d309976a 100644 --- a/app/javascript/flavours/glitch/features/status/index.js +++ b/app/javascript/flavours/glitch/features/status/index.js @@ -38,6 +38,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import { HotKeys } from 'react-hotkeys'; import { boostModal, favouriteModal, deleteModal } from 'flavours/glitch/util/initial_state'; import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from 'flavours/glitch/util/fullscreen'; +import { autoUnfoldCW } from 'flavours/glitch/util/content_warning'; const messages = defineMessages({ deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, @@ -82,7 +83,7 @@ export default class Status extends ImmutablePureComponent { state = { fullscreen: false, - isExpanded: this.props.settings.getIn(['content_warnings', 'auto_unfold']), + isExpanded: undefined, threadExpanded: undefined, }; @@ -95,9 +96,14 @@ export default class Status extends ImmutablePureComponent { } componentWillReceiveProps (nextProps) { + if (this.state.isExpanded === undefined) { + const isExpanded = autoUnfoldCW(nextProps.settings, nextProps.status); + if (isExpanded !== undefined) this.setState({ isExpanded: isExpanded }); + } if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) { this._scrolledIntoView = false; this.props.dispatch(fetchStatus(nextProps.params.statusId)); + this.setState({ isExpanded: autoUnfoldCW(nextProps.settings, nextProps.status) }); } } diff --git a/app/javascript/flavours/glitch/reducers/local_settings.js b/app/javascript/flavours/glitch/reducers/local_settings.js index ce33cac83..063ae3943 100644 --- a/app/javascript/flavours/glitch/reducers/local_settings.js +++ b/app/javascript/flavours/glitch/reducers/local_settings.js @@ -16,6 +16,7 @@ const initialState = ImmutableMap({ confirm_missing_media_description: false, content_warnings : ImmutableMap({ auto_unfold : false, + filter : null, }), collapsed : ImmutableMap({ enabled : true, diff --git a/app/javascript/flavours/glitch/util/content_warning.js b/app/javascript/flavours/glitch/util/content_warning.js new file mode 100644 index 000000000..29e221c8e --- /dev/null +++ b/app/javascript/flavours/glitch/util/content_warning.js @@ -0,0 +1,19 @@ +export function autoUnfoldCW (settings, status) { + if (!settings.getIn(['content_warnings', 'auto_unfold'])) { + return false; + } + + const rawRegex = settings.getIn(['content_warnings', 'filter']); + let regex = null; + + try { + regex = rawRegex && new RegExp(rawRegex.trim(), 'i'); + } catch (e) { + // Bad regex, don't affect filters + } + + if (!(status && regex)) { + return undefined; + } + return !regex.test(status.get('spoiler_text')); +} -- cgit From b3fdd166e819819a7a8f7cfa540986af047c05fa Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 3 Sep 2018 17:30:55 +0200 Subject: [Glitch] Skip VS15 (Emoji textual presentation) Port a060beee726de5295e1f608231975a90b7709a0a to glitch-soc --- app/javascript/flavours/glitch/util/emoji/index.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/javascript/flavours/glitch/util') diff --git a/app/javascript/flavours/glitch/util/emoji/index.js b/app/javascript/flavours/glitch/util/emoji/index.js index c6416db2d..82a1ef89c 100644 --- a/app/javascript/flavours/glitch/util/emoji/index.js +++ b/app/javascript/flavours/glitch/util/emoji/index.js @@ -62,6 +62,10 @@ const emojify = (str, customEmojis = {}) => { const title = shortCode ? `:${shortCode}:` : ''; replacement = `${match}`; rend = i + match.length; + // If the matched character was followed by VS15 (for selecting text presentation), skip it. + if (str.codePointAt(rend) === 65038) { + rend += 1; + } } rtn += str.slice(0, i) + replacement; str = str.slice(rend); -- cgit From 6ad7dac79130bb7b68ccb703739167a737ed6b49 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 31 Aug 2018 12:10:38 +0200 Subject: Let the front-end know the current account is a moderator --- app/javascript/flavours/glitch/util/initial_state.js | 1 + app/serializers/initial_state_serializer.rb | 1 + 2 files changed, 2 insertions(+) (limited to 'app/javascript/flavours/glitch/util') diff --git a/app/javascript/flavours/glitch/util/initial_state.js b/app/javascript/flavours/glitch/util/initial_state.js index 236ea1c3a..fdf004527 100644 --- a/app/javascript/flavours/glitch/util/initial_state.js +++ b/app/javascript/flavours/glitch/util/initial_state.js @@ -21,5 +21,6 @@ export const deleteModal = getMeta('delete_modal'); export const me = getMeta('me'); export const searchEnabled = getMeta('search_enabled'); export const maxChars = (initialState && initialState.max_toot_chars) || 500; +export const isStaff = getMeta('is_staff'); export default initialState; diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 204a13b55..0845d0210 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -32,6 +32,7 @@ class InitialStateSerializer < ActiveModel::Serializer store[:auto_play_gif] = object.current_account.user.setting_auto_play_gif store[:display_sensitive_media] = object.current_account.user.setting_display_sensitive_media store[:reduce_motion] = object.current_account.user.setting_reduce_motion + store[:is_staff] = object.current_account.user.staff? end store -- cgit