From a75138d07336c2f10a8cbdba86f72f08c81cf9d7 Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Thu, 13 Jul 2023 11:28:55 +0200 Subject: [PATCH 1/2] Convert Home timeline components to Typescript (#25583) --- .../components/column_settings.jsx | 38 ----------- .../components/column_settings.tsx | 66 +++++++++++++++++++ .../components/explore_prompt.jsx | 25 ------- .../components/explore_prompt.tsx | 46 +++++++++++++ .../containers/column_settings_container.js | 22 ------- .../mastodon/features/home_timeline/index.jsx | 4 +- 6 files changed, 114 insertions(+), 87 deletions(-) delete mode 100644 app/javascript/mastodon/features/home_timeline/components/column_settings.jsx create mode 100644 app/javascript/mastodon/features/home_timeline/components/column_settings.tsx delete mode 100644 app/javascript/mastodon/features/home_timeline/components/explore_prompt.jsx create mode 100644 app/javascript/mastodon/features/home_timeline/components/explore_prompt.tsx delete mode 100644 app/javascript/mastodon/features/home_timeline/containers/column_settings_container.js diff --git a/app/javascript/mastodon/features/home_timeline/components/column_settings.jsx b/app/javascript/mastodon/features/home_timeline/components/column_settings.jsx deleted file mode 100644 index b6e6b9cff6..0000000000 --- a/app/javascript/mastodon/features/home_timeline/components/column_settings.jsx +++ /dev/null @@ -1,38 +0,0 @@ -import PropTypes from 'prop-types'; -import { PureComponent } from 'react'; - -import { injectIntl, FormattedMessage } from 'react-intl'; - -import ImmutablePropTypes from 'react-immutable-proptypes'; - -import SettingToggle from '../../notifications/components/setting_toggle'; - -class ColumnSettings extends PureComponent { - - static propTypes = { - settings: ImmutablePropTypes.map.isRequired, - onChange: PropTypes.func.isRequired, - intl: PropTypes.object.isRequired, - }; - - render () { - const { settings, onChange } = this.props; - - return ( -
- - -
- } /> -
- -
- } /> -
-
- ); - } - -} - -export default injectIntl(ColumnSettings); diff --git a/app/javascript/mastodon/features/home_timeline/components/column_settings.tsx b/app/javascript/mastodon/features/home_timeline/components/column_settings.tsx new file mode 100644 index 0000000000..477e94c9c5 --- /dev/null +++ b/app/javascript/mastodon/features/home_timeline/components/column_settings.tsx @@ -0,0 +1,66 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call, + @typescript-eslint/no-unsafe-return, + @typescript-eslint/no-unsafe-assignment, + @typescript-eslint/no-unsafe-member-access + -- the settings store is not yet typed */ +import { useCallback } from 'react'; + +import { FormattedMessage } from 'react-intl'; + +import { useAppSelector, useAppDispatch } from 'mastodon/store'; + +import { changeSetting } from '../../../actions/settings'; +import SettingToggle from '../../notifications/components/setting_toggle'; + +export const ColumnSettings: React.FC = () => { + const settings = useAppSelector((state) => state.settings.get('home')); + + const dispatch = useAppDispatch(); + const onChange = useCallback( + (key: string, checked: boolean) => { + void dispatch(changeSetting(['home', ...key], checked)); + }, + [dispatch] + ); + + return ( +
+ + + + +
+ + } + /> +
+ +
+ + } + /> +
+
+ ); +}; diff --git a/app/javascript/mastodon/features/home_timeline/components/explore_prompt.jsx b/app/javascript/mastodon/features/home_timeline/components/explore_prompt.jsx deleted file mode 100644 index 2af85b6d54..0000000000 --- a/app/javascript/mastodon/features/home_timeline/components/explore_prompt.jsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; - -import { FormattedMessage } from 'react-intl'; - -import { Link } from 'react-router-dom'; - -import background from 'mastodon/../images/friends-cropped.png'; -import { DismissableBanner } from 'mastodon/components/dismissable_banner'; - - -export const ExplorePrompt = () => ( - - - -

-

- -
-
- - -
-
-
-); diff --git a/app/javascript/mastodon/features/home_timeline/components/explore_prompt.tsx b/app/javascript/mastodon/features/home_timeline/components/explore_prompt.tsx new file mode 100644 index 0000000000..47113d9b8e --- /dev/null +++ b/app/javascript/mastodon/features/home_timeline/components/explore_prompt.tsx @@ -0,0 +1,46 @@ +import { FormattedMessage } from 'react-intl'; + +import { Link } from 'react-router-dom'; + +import background from 'mastodon/../images/friends-cropped.png'; +import { DismissableBanner } from 'mastodon/components/dismissable_banner'; + +export const ExplorePrompt = () => ( + + + +

+ +

+

+ +

+ +
+
+ + + + + + +
+
+
+); diff --git a/app/javascript/mastodon/features/home_timeline/containers/column_settings_container.js b/app/javascript/mastodon/features/home_timeline/containers/column_settings_container.js deleted file mode 100644 index 1ddec6da9c..0000000000 --- a/app/javascript/mastodon/features/home_timeline/containers/column_settings_container.js +++ /dev/null @@ -1,22 +0,0 @@ -import { connect } from 'react-redux'; - -import { changeSetting, saveSettings } from '../../../actions/settings'; -import ColumnSettings from '../components/column_settings'; - -const mapStateToProps = state => ({ - settings: state.getIn(['settings', 'home']), -}); - -const mapDispatchToProps = dispatch => ({ - - onChange (key, checked) { - dispatch(changeSetting(['home', ...key], checked)); - }, - - onSave () { - dispatch(saveSettings()); - }, - -}); - -export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings); diff --git a/app/javascript/mastodon/features/home_timeline/index.jsx b/app/javascript/mastodon/features/home_timeline/index.jsx index ae98aec0a6..1cd6edd7aa 100644 --- a/app/javascript/mastodon/features/home_timeline/index.jsx +++ b/app/javascript/mastodon/features/home_timeline/index.jsx @@ -22,8 +22,8 @@ import Column from '../../components/column'; import ColumnHeader from '../../components/column_header'; import StatusListContainer from '../ui/containers/status_list_container'; +import { ColumnSettings } from './components/column_settings'; import { ExplorePrompt } from './components/explore_prompt'; -import ColumnSettingsContainer from './containers/column_settings_container'; const messages = defineMessages({ title: { id: 'column.home', defaultMessage: 'Home' }, @@ -191,7 +191,7 @@ class HomeTimeline extends PureComponent { extraButton={announcementsButton} appendContent={hasAnnouncements && showAnnouncements && } > - + {signedIn ? ( From 3ed9b55cb3987e3d32c56f857cb6903ca8bec3d4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Jul 2023 11:44:02 +0200 Subject: [PATCH 2/2] Update dependency rubocop-rails to v2.20.1 (#25493) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Renaud Chaput --- Gemfile.lock | 2 +- app/serializers/web/notification_serializer.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7cd102c5ad..87d8ef7d25 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -616,7 +616,7 @@ GEM rubocop-performance (1.18.0) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.19.1) + rubocop-rails (2.20.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) diff --git a/app/serializers/web/notification_serializer.rb b/app/serializers/web/notification_serializer.rb index c5a908b199..fb2f7248a6 100644 --- a/app/serializers/web/notification_serializer.rb +++ b/app/serializers/web/notification_serializer.rb @@ -33,7 +33,7 @@ class Web::NotificationSerializer < ActiveModel::Serializer end def body - str = strip_tags(object.target_status&.spoiler_text&.presence || object.target_status&.text || object.from_account.note) + str = strip_tags(object.target_status&.spoiler_text.presence || object.target_status&.text || object.from_account.note) truncate(HTMLEntities.new.decode(str.to_str), length: 140, escape: false) # Do not encode entities, since this value will not be used in HTML end end