Reports Counter: Only fetch reports when user is staff
This commit is contained in:
parent
c3c77c1795
commit
ebea858ca2
1 changed files with 20 additions and 13 deletions
|
@ -35,6 +35,7 @@ import SidebarMenu from '../../components/sidebar_menu';
|
||||||
import { connectUserStream } from '../../actions/streaming';
|
import { connectUserStream } from '../../actions/streaming';
|
||||||
import { Redirect } from 'react-router-dom';
|
import { Redirect } from 'react-router-dom';
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
|
import { isStaff } from 'soapbox/utils/accounts';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Status,
|
Status,
|
||||||
|
@ -90,7 +91,7 @@ const messages = defineMessages({
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
const me = state.get('me');
|
const me = state.get('me');
|
||||||
const meUsername = state.getIn(['accounts', me, 'username']);
|
const account = state.getIn(['accounts', me]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isComposing: state.getIn(['compose', 'is_composing']),
|
isComposing: state.getIn(['compose', 'is_composing']),
|
||||||
|
@ -100,7 +101,7 @@ const mapStateToProps = state => {
|
||||||
accessToken: state.getIn(['auth', 'user', 'access_token']),
|
accessToken: state.getIn(['auth', 'user', 'access_token']),
|
||||||
streamingUrl: state.getIn(['instance', 'urls', 'streaming_api']),
|
streamingUrl: state.getIn(['instance', 'urls', 'streaming_api']),
|
||||||
me,
|
me,
|
||||||
meUsername,
|
account,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -285,7 +286,7 @@ class UI extends React.PureComponent {
|
||||||
dropdownMenuIsOpen: PropTypes.bool,
|
dropdownMenuIsOpen: PropTypes.bool,
|
||||||
me: SoapboxPropTypes.me,
|
me: SoapboxPropTypes.me,
|
||||||
streamingUrl: PropTypes.string,
|
streamingUrl: PropTypes.string,
|
||||||
meUsername: PropTypes.string,
|
account: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -399,8 +400,8 @@ class UI extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { me } = this.props;
|
const { account } = this.props;
|
||||||
if (!me) return;
|
if (!account) return;
|
||||||
window.addEventListener('beforeunload', this.handleBeforeUnload, false);
|
window.addEventListener('beforeunload', this.handleBeforeUnload, false);
|
||||||
|
|
||||||
document.addEventListener('dragenter', this.handleDragEnter, false);
|
document.addEventListener('dragenter', this.handleDragEnter, false);
|
||||||
|
@ -417,11 +418,11 @@ class UI extends React.PureComponent {
|
||||||
window.setTimeout(() => Notification.requestPermission(), 120 * 1000);
|
window.setTimeout(() => Notification.requestPermission(), 120 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me) {
|
if (account) {
|
||||||
this.props.dispatch(expandHomeTimeline());
|
this.props.dispatch(expandHomeTimeline());
|
||||||
this.props.dispatch(expandNotifications());
|
this.props.dispatch(expandNotifications());
|
||||||
// this.props.dispatch(fetchGroups('member'));
|
// this.props.dispatch(fetchGroups('member'));
|
||||||
this.props.dispatch(fetchReports());
|
if (isStaff(account)) this.props.dispatch(fetchReports());
|
||||||
|
|
||||||
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
||||||
}
|
}
|
||||||
|
@ -524,18 +525,24 @@ class UI extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyGoToFavourites = () => {
|
handleHotkeyGoToFavourites = () => {
|
||||||
const { meUsername } = this.props;
|
const { account } = this.props;
|
||||||
this.context.router.history.push(`/${meUsername}/favorites`);
|
if (!account) return;
|
||||||
|
|
||||||
|
this.context.router.history.push(`/${account.get('username')}/favorites`);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyGoToPinned = () => {
|
handleHotkeyGoToPinned = () => {
|
||||||
const { meUsername } = this.props;
|
const { account } = this.props;
|
||||||
this.context.router.history.push(`/${meUsername}/pins`);
|
if (!account) return;
|
||||||
|
|
||||||
|
this.context.router.history.push(`/${account.get('username')}/pins`);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyGoToProfile = () => {
|
handleHotkeyGoToProfile = () => {
|
||||||
const { meUsername } = this.props;
|
const { account } = this.props;
|
||||||
this.context.router.history.push(`/${meUsername}`);
|
if (!account) return;
|
||||||
|
|
||||||
|
this.context.router.history.push(`/${account.get('username')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyGoToBlocked = () => {
|
handleHotkeyGoToBlocked = () => {
|
||||||
|
|
Loading…
Reference in a new issue