]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix empty “Server rules violation” report option
authorClaire <claire.github-309c@sitedethib.com>
Thu, 28 Apr 2022 19:29:29 +0000 (21:29 +0200)
committersingle-right-quote <11325618-aescling@users.noreply.gitlab.com>
Thu, 5 May 2022 17:49:12 +0000 (13:49 -0400)
Port eed5a4bf9c7e41a03ebab92dd45ebc1b899dc768 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
app/javascript/flavours/glitch/features/report/category.js
app/javascript/flavours/glitch/features/ui/index.js

index cf63533d07675fef0d198fd32662a5a902e4b9eb..4c71ccde702d1fdd507197befc8b24b71fba6679 100644 (file)
@@ -1,5 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import { connect } from 'react-redux';
 import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
 import Button from 'flavours/glitch/components/button';
 import Option from './components/option';
@@ -17,11 +19,17 @@ const messages = defineMessages({
   account: { id: 'report.category.title_account', defaultMessage: 'profile' },
 });
 
-export default @injectIntl
+const mapStateToProps = state => ({
+  rules: state.get('rules'),
+});
+
+export default @connect(mapStateToProps)
+@injectIntl
 class Category extends React.PureComponent {
 
   static propTypes = {
     onNextStep: PropTypes.func.isRequired,
+    rules: ImmutablePropTypes.list,
     category: PropTypes.string,
     onChangeCategory: PropTypes.func.isRequired,
     startedFrom: PropTypes.oneOf(['status', 'account']),
@@ -53,13 +61,17 @@ class Category extends React.PureComponent {
   };
 
   render () {
-    const { category, startedFrom, intl } = this.props;
+    const { category, startedFrom, rules, intl } = this.props;
 
-    const options = [
+    const options = rules.size > 0 ? [
       'dislike',
       'spam',
       'violation',
       'other',
+    ] : [
+      'dislike',
+      'spam',
+      'other',
     ];
 
     return (
index 7ca1adf7cc426b1985923800208544001c24f862..099ffc69c701039a5ef5ad6a40245c2e340a0474 100644 (file)
@@ -11,6 +11,7 @@ import { uploadCompose, resetCompose, changeComposeSpoilerness } from 'flavours/
 import { expandHomeTimeline } from 'flavours/glitch/actions/timelines';
 import { expandNotifications, notificationsSetVisibility } from 'flavours/glitch/actions/notifications';
 import { fetchFilters } from 'flavours/glitch/actions/filters';
+import { fetchRules } from 'flavours/glitch/actions/rules';
 import { clearHeight } from 'flavours/glitch/actions/height_cache';
 import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'flavours/glitch/actions/markers';
 import { WrappedSwitch, WrappedRoute } from 'flavours/glitch/util/react_router_helpers';
@@ -402,6 +403,7 @@ class UI extends React.Component {
     this.props.dispatch(expandHomeTimeline());
     this.props.dispatch(expandNotifications());
     setTimeout(() => this.props.dispatch(fetchFilters()), 500);
+    setTimeout(() => this.props.dispatch(fetchRules()), 3000);
   }
 
   componentDidMount () {