From ef665c1df5821e684c8da3392049f33243fafa74 Mon Sep 17 00:00:00 2001 From: Dean Bassett Date: Thu, 29 Dec 2022 17:26:08 -0800 Subject: [PATCH] add configuration option for autocollapse (#2) --- .../flavours/glitch/components/status.js | 4 ++++ .../glitch/features/local_settings/page/index.js | 14 +++++++++++++- .../features/local_settings/page/item/index.js | 13 ++++++++++--- app/javascript/flavours/glitch/locales/en.json | 1 + .../flavours/glitch/reducers/local_settings.js | 1 + 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index 4041b48194..d00a9bf5c6 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -251,6 +251,10 @@ class Status extends ImmutablePureComponent { // as it could cause surprising changes when receiving notifications if (settings.getIn(['content_warnings', 'shared_state']) && status.get('spoiler_text').length && !status.get('hidden')) return; + let autoCollapseHeight = autoCollapseSettings.get('height'); + if (status.get('media_attachments').size && !muted) { + autoCollapseHeight += 300; + } if (collapse || autoCollapseSettings.get('all') || (autoCollapseSettings.get('notifications') && muted) || 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 d01eec811e..bc4a250793 100644 --- a/app/javascript/flavours/glitch/features/local_settings/page/index.js +++ b/app/javascript/flavours/glitch/features/local_settings/page/index.js @@ -5,7 +5,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; // Our imports -import { expandSpoilers, disableSwiping } from 'flavours/glitch/initial_state'; +import { expandSpoilers } from 'flavours/glitch/initial_state'; import { preferenceLink } from 'flavours/glitch/utils/backend_links'; import LocalSettingsPageItem from './item'; import DeprecatedLocalSettingsPageItem from './deprecated_item'; @@ -406,6 +406,18 @@ class LocalSettingsPage extends React.PureComponent { > + + +

diff --git a/app/javascript/flavours/glitch/features/local_settings/page/item/index.js b/app/javascript/flavours/glitch/features/local_settings/page/item/index.js index 6b24e41435..5632c468cc 100644 --- a/app/javascript/flavours/glitch/features/local_settings/page/item/index.js +++ b/app/javascript/flavours/glitch/features/local_settings/page/item/index.js @@ -14,6 +14,7 @@ export default class LocalSettingsPageItem extends React.PureComponent { id: PropTypes.string.isRequired, item: PropTypes.array.isRequired, onChange: PropTypes.func.isRequired, + inputProps: PropTypes.object, options: PropTypes.arrayOf(PropTypes.shape({ value: PropTypes.string.isRequired, message: PropTypes.string.isRequired, @@ -27,6 +28,7 @@ export default class LocalSettingsPageItem extends React.PureComponent { handleChange = e => { const { target } = e; const { item, onChange, options, placeholder } = this.props; + if (options && options.length > 0) onChange(item, target.value); else if (placeholder) onChange(item, target.value); else onChange(item, target.checked); @@ -34,7 +36,7 @@ export default class LocalSettingsPageItem extends React.PureComponent { render () { const { handleChange } = this; - const { settings, item, id, options, children, dependsOn, dependsOnNot, placeholder, disabled } = this.props; + const { settings, item, id, inputProps, options, children, dependsOn, dependsOnNot, placeholder, disabled } = this.props; let enabled = !disabled; if (dependsOn) { @@ -54,14 +56,17 @@ export default class LocalSettingsPageItem extends React.PureComponent { let optionId = `${id}--${opt.value}`; return ( @@ -103,6 +109,7 @@ export default class LocalSettingsPageItem extends React.PureComponent { checked={settings.getIn(item)} onChange={handleChange} disabled={!enabled} + {...inputProps} /> {children} diff --git a/app/javascript/flavours/glitch/locales/en.json b/app/javascript/flavours/glitch/locales/en.json index 59f2f74b1e..3a24d666cb 100644 --- a/app/javascript/flavours/glitch/locales/en.json +++ b/app/javascript/flavours/glitch/locales/en.json @@ -103,6 +103,7 @@ "settings.auto_collapse_all": "Everything", "settings.auto_collapse_lengthy": "Lengthy toots", "settings.auto_collapse_media": "Toots with media", + "settings.auto_collapse_height": "Maximum height (pixels) of toots before auto-collapsing", "settings.auto_collapse_notifications": "Notifications", "settings.auto_collapse_reblogs": "Boosts", "settings.auto_collapse_replies": "Replies", diff --git a/app/javascript/flavours/glitch/reducers/local_settings.js b/app/javascript/flavours/glitch/reducers/local_settings.js index 81ab1cb0d8..1cbfb31fa7 100644 --- a/app/javascript/flavours/glitch/reducers/local_settings.js +++ b/app/javascript/flavours/glitch/reducers/local_settings.js @@ -37,6 +37,7 @@ const initialState = ImmutableMap({ reblogs : false, replies : false, media : false, + height : 500, }), backgrounds : ImmutableMap({ user_backgrounds : false,