[Glitch] Put "Media Only" option in column settings instead of content area headline
Port 4f42238c29
to glitch-soc
This commit is contained in:
@@ -1,17 +1,28 @@
|
||||
import { connect } from 'react-redux';
|
||||
import ColumnSettings from 'flavours/glitch/features/community_timeline/components/column_settings';
|
||||
import { changeSetting } from 'flavours/glitch/actions/settings';
|
||||
import { changeColumnParams } from 'flavours/glitch/actions/columns';
|
||||
|
||||
const mapStateToProps = (state, { columnId }) => {
|
||||
const uuid = columnId;
|
||||
const columns = state.getIn(['settings', 'columns']);
|
||||
const index = columns.findIndex(c => c.get('uuid') === uuid);
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
settings: state.getIn(['settings', 'public']),
|
||||
});
|
||||
return {
|
||||
settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'public']),
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
||||
onChange (path, checked) {
|
||||
dispatch(changeSetting(['public', ...path], checked));
|
||||
},
|
||||
|
||||
});
|
||||
const mapDispatchToProps = (dispatch, { columnId }) => {
|
||||
return {
|
||||
onChange (key, checked) {
|
||||
if (columnId) {
|
||||
dispatch(changeColumnParams(columnId, key, checked));
|
||||
} else {
|
||||
dispatch(changeSetting(['public', ...key], checked));
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);
|
||||
|
@@ -6,18 +6,24 @@ import StatusListContainer from 'flavours/glitch/features/ui/containers/status_l
|
||||
import Column from 'flavours/glitch/components/column';
|
||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||
import { expandPublicTimeline } from 'flavours/glitch/actions/timelines';
|
||||
import { addColumn, removeColumn, moveColumn, changeColumnParams } from 'flavours/glitch/actions/columns';
|
||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||
import SectionHeadline from '../community_timeline/components/section_headline';
|
||||
import { connectPublicStream } from 'flavours/glitch/actions/streaming';
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'column.public', defaultMessage: 'Federated timeline' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, { onlyMedia }) => ({
|
||||
hasUnread: state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`, 'unread']) > 0,
|
||||
});
|
||||
const mapStateToProps = (state, { onlyMedia, columnId }) => {
|
||||
const uuid = columnId;
|
||||
const columns = state.getIn(['settings', 'columns']);
|
||||
const index = columns.findIndex(c => c.get('uuid') === uuid);
|
||||
|
||||
return {
|
||||
hasUnread: state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`, 'unread']) > 0,
|
||||
onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'public', 'other', 'onlyMedia']),
|
||||
};
|
||||
};
|
||||
|
||||
@connect(mapStateToProps)
|
||||
@injectIntl
|
||||
@@ -27,6 +33,10 @@ export default class PublicTimeline extends React.PureComponent {
|
||||
onlyMedia: false,
|
||||
};
|
||||
|
||||
static contextTypes = {
|
||||
router: PropTypes.object,
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
@@ -93,27 +103,17 @@ export default class PublicTimeline extends React.PureComponent {
|
||||
return !(location.state && location.state.mastodonModalOpen)
|
||||
}
|
||||
|
||||
handleHeadlineLinkClick = e => {
|
||||
const { columnId, dispatch } = this.props;
|
||||
const onlyMedia = /\/media$/.test(e.currentTarget.href);
|
||||
|
||||
dispatch(changeColumnParams(columnId, { other: { onlyMedia } }));
|
||||
handleSettingChanged = (key, checked) => {
|
||||
const { columnId } = this.props;
|
||||
if (!columnId && key[0] === 'other' && key[1] === 'onlyMedia') {
|
||||
this.context.router.history.replace(`/timelines/public${checked ? '/media' : ''}`);
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
const { intl, columnId, hasUnread, multiColumn, onlyMedia } = this.props;
|
||||
const pinned = !!columnId;
|
||||
|
||||
const headline = (
|
||||
<SectionHeadline
|
||||
timelineId='public'
|
||||
to='/timelines/public'
|
||||
pinned={pinned}
|
||||
onlyMedia={onlyMedia}
|
||||
onClick={this.handleHeadlineLinkClick}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<Column ref={this.setRef} name='federated' label={intl.formatMessage(messages.title)}>
|
||||
<ColumnHeader
|
||||
@@ -126,12 +126,10 @@ export default class PublicTimeline extends React.PureComponent {
|
||||
pinned={pinned}
|
||||
multiColumn={multiColumn}
|
||||
>
|
||||
<ColumnSettingsContainer />
|
||||
<ColumnSettingsContainer onChange={this.handleSettingChanged} columnId={columnId} />
|
||||
</ColumnHeader>
|
||||
|
||||
<StatusListContainer
|
||||
prepend={headline}
|
||||
alwaysPrepend
|
||||
timelineId={`public${onlyMedia ? ':media' : ''}`}
|
||||
onLoadMore={this.handleLoadMore}
|
||||
trackScroll={!pinned}
|
||||
|
Reference in New Issue
Block a user