Removed unused columnId throughout app

This commit is contained in:
mgabdev 2019-07-10 14:20:31 -04:00
parent a385210c09
commit 038e7db5b9
12 changed files with 36 additions and 84 deletions

View File

@ -11,7 +11,6 @@ class ColumnSettings extends React.PureComponent {
settings: ImmutablePropTypes.map.isRequired, settings: ImmutablePropTypes.map.isRequired,
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
columnId: PropTypes.string,
}; };
render () { render () {

View File

@ -1,26 +1,15 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ColumnSettings from '../components/column_settings'; import ColumnSettings from '../components/column_settings';
import { changeSetting } from '../../../actions/settings'; import { changeSetting } from '../../../actions/settings';
import { changeColumnParams } from '../../../actions/columns';
const mapStateToProps = (state, { columnId }) => { const mapStateToProps = state => ({
const uuid = columnId; settings: state.getIn(['settings', 'community']),
const columns = state.getIn(['settings', 'columns']); });
const index = columns.findIndex(c => c.get('uuid') === uuid);
return { const mapDispatchToProps = (dispatch) => {
settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'community']),
};
};
const mapDispatchToProps = (dispatch, { columnId }) => {
return { return {
onChange (key, checked) { onChange (key, checked) {
if (columnId) { dispatch(changeSetting(['community', ...key], checked));
dispatch(changeColumnParams(columnId, key, checked));
} else {
dispatch(changeSetting(['community', ...key], checked));
}
}, },
}; };
}; };

View File

@ -13,16 +13,10 @@ const messages = defineMessages({
title: { id: 'column.community', defaultMessage: 'Local timeline' }, title: { id: 'column.community', defaultMessage: 'Local timeline' },
}); });
const mapStateToProps = (state, { onlyMedia, columnId }) => { const mapStateToProps = (state, { onlyMedia }) => ({
const uuid = columnId; hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0,
const columns = state.getIn(['settings', 'columns']); onlyMedia: state.getIn(['settings', 'community', 'other', 'onlyMedia']),
const index = columns.findIndex(c => c.get('uuid') === uuid); });
return {
hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0,
onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']),
};
};
export default @connect(mapStateToProps) export default @connect(mapStateToProps)
@injectIntl @injectIntl
@ -38,7 +32,6 @@ class CommunityTimeline extends React.PureComponent {
static propTypes = { static propTypes = {
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
columnId: PropTypes.string,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
hasUnread: PropTypes.bool, hasUnread: PropTypes.bool,
onlyMedia: PropTypes.bool, onlyMedia: PropTypes.bool,
@ -75,7 +68,7 @@ class CommunityTimeline extends React.PureComponent {
} }
render () { render () {
const { intl, hasUnread, columnId, onlyMedia } = this.props; const { intl, hasUnread, onlyMedia } = this.props;
return ( return (
<Column label={intl.formatMessage(messages.title)}> <Column label={intl.formatMessage(messages.title)}>
@ -86,7 +79,7 @@ class CommunityTimeline extends React.PureComponent {
<ColumnSettingsContainer /> <ColumnSettingsContainer />
</HomeColumnHeader> </HomeColumnHeader>
<StatusListContainer <StatusListContainer
scrollKey={`community_timeline-${columnId}`} scrollKey='community_timeline'
timelineId={`community${onlyMedia ? ':media' : ''}`} timelineId={`community${onlyMedia ? ':media' : ''}`}
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />} emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />}

View File

@ -18,7 +18,6 @@ class DirectTimeline extends React.PureComponent {
static propTypes = { static propTypes = {
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
columnId: PropTypes.string,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
hasUnread: PropTypes.bool, hasUnread: PropTypes.bool,
}; };
@ -45,14 +44,14 @@ class DirectTimeline extends React.PureComponent {
} }
render () { render () {
const { intl, hasUnread, columnId } = this.props; const { intl, hasUnread } = this.props;
return ( return (
<Column label={intl.formatMessage(messages.title)}> <Column label={intl.formatMessage(messages.title)}>
<ColumnHeader icon='envelope' active={hasUnread} title={intl.formatMessage(messages.title)} /> <ColumnHeader icon='envelope' active={hasUnread} title={intl.formatMessage(messages.title)} />
<ConversationsListContainer <ConversationsListContainer
scrollKey={`direct_timeline-${columnId}`} scrollKey='direct_timeline'
timelineId='direct' timelineId='direct'
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.direct' defaultMessage="You don't have any direct messages yet. When you send or receive one, it will show up here." />} emptyMessage={<FormattedMessage id='empty_column.direct' defaultMessage="You don't have any direct messages yet. When you send or receive one, it will show up here." />}

View File

@ -29,7 +29,6 @@ class Favourites extends ImmutablePureComponent {
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
statusIds: ImmutablePropTypes.list.isRequired, statusIds: ImmutablePropTypes.list.isRequired,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
columnId: PropTypes.string,
hasMore: PropTypes.bool, hasMore: PropTypes.bool,
isLoading: PropTypes.bool, isLoading: PropTypes.bool,
isMyAccount: PropTypes.bool.isRequired, isMyAccount: PropTypes.bool.isRequired,
@ -44,7 +43,7 @@ class Favourites extends ImmutablePureComponent {
}, 300, { leading: true }) }, 300, { leading: true })
render () { render () {
const { intl, statusIds, columnId, hasMore, isLoading, isMyAccount } = this.props; const { intl, statusIds, hasMore, isLoading, isMyAccount } = this.props;
if (!isMyAccount) { if (!isMyAccount) {
return ( return (
@ -60,7 +59,7 @@ class Favourites extends ImmutablePureComponent {
<Column> <Column>
<StatusList <StatusList
statusIds={statusIds} statusIds={statusIds}
scrollKey={`favourited_statuses-${columnId}`} scrollKey='favourited_statuses'
hasMore={hasMore} hasMore={hasMore}
isLoading={isLoading} isLoading={isLoading}
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}

View File

@ -30,7 +30,6 @@ class GroupTimeline extends React.PureComponent {
static propTypes = { static propTypes = {
params: PropTypes.object.isRequired, params: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
columnId: PropTypes.string,
hasUnread: PropTypes.bool, hasUnread: PropTypes.bool,
group: PropTypes.oneOfType([ImmutablePropTypes.map, PropTypes.bool]), group: PropTypes.oneOfType([ImmutablePropTypes.map, PropTypes.bool]),
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
@ -59,7 +58,7 @@ class GroupTimeline extends React.PureComponent {
} }
render () { render () {
const { hasUnread, columnId, group } = this.props; const { hasUnread, group } = this.props;
const { id } = this.props.params; const { id } = this.props.params;
const title = group ? group.get('title') : id; const title = group ? group.get('title') : id;
@ -93,7 +92,7 @@ class GroupTimeline extends React.PureComponent {
<StatusListContainer <StatusListContainer
prepend={<HeaderContainer groupId={id} />} prepend={<HeaderContainer groupId={id} />}
alwaysPrepend alwaysPrepend
scrollKey={`group_timeline-${columnId}`} scrollKey='group_timeline'
timelineId={`group:${id}`} timelineId={`group:${id}`}
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.group' defaultMessage='There is nothing in this group yet. When members of this group post new statuses, they will appear here.' />} emptyMessage={<FormattedMessage id='empty_column.group' defaultMessage='There is nothing in this group yet. When members of this group post new statuses, they will appear here.' />}

View File

@ -21,7 +21,6 @@ class HashtagTimeline extends React.PureComponent {
static propTypes = { static propTypes = {
params: PropTypes.object.isRequired, params: PropTypes.object.isRequired,
columnId: PropTypes.string,
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
hasUnread: PropTypes.bool, hasUnread: PropTypes.bool,
}; };
@ -104,17 +103,14 @@ class HashtagTimeline extends React.PureComponent {
} }
render () { render () {
const { hasUnread, columnId } = this.props; const { hasUnread } = this.props;
const { id } = this.props.params; const { id } = this.props.params;
return ( return (
<Column label={`#${id}`}> <Column label={`#${id}`}>
<ColumnHeader icon='hashtag' active={hasUnread} title={this.title()}> <ColumnHeader icon='hashtag' active={hasUnread} title={this.title()} />
{columnId && <ColumnSettingsContainer columnId={columnId} />}
</ColumnHeader>
<StatusListContainer <StatusListContainer
scrollKey={`hashtag_timeline-${columnId}`} scrollKey='hashtag_timeline'
timelineId={`hashtag:${id}`} timelineId={`hashtag:${id}`}
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.hashtag' defaultMessage='There is nothing in this hashtag yet.' />} emptyMessage={<FormattedMessage id='empty_column.hashtag' defaultMessage='There is nothing in this hashtag yet.' />}

View File

@ -26,7 +26,6 @@ class HomeTimeline extends React.PureComponent {
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
hasUnread: PropTypes.bool, hasUnread: PropTypes.bool,
isPartial: PropTypes.bool, isPartial: PropTypes.bool,
columnId: PropTypes.string,
}; };
handleLoadMore = maxId => { handleLoadMore = maxId => {
@ -67,7 +66,7 @@ class HomeTimeline extends React.PureComponent {
} }
render () { render () {
const { intl, hasUnread, columnId } = this.props; const { intl, hasUnread } = this.props;
return ( return (
<Column label={intl.formatMessage(messages.title)}> <Column label={intl.formatMessage(messages.title)}>
@ -78,7 +77,7 @@ class HomeTimeline extends React.PureComponent {
<ColumnSettingsContainer /> <ColumnSettingsContainer />
</HomeColumnHeader> </HomeColumnHeader>
<StatusListContainer <StatusListContainer
scrollKey={`home_timeline-${columnId}`} scrollKey='home_timeline'
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
timelineId='home' timelineId='home'
emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty. Start following other users to recieve their content here.'/>} emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty. Start following other users to recieve their content here.'/>}

View File

@ -36,7 +36,6 @@ class ListTimeline extends React.PureComponent {
static propTypes = { static propTypes = {
params: PropTypes.object.isRequired, params: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
columnId: PropTypes.string,
hasUnread: PropTypes.bool, hasUnread: PropTypes.bool,
list: PropTypes.oneOfType([ImmutablePropTypes.map, PropTypes.bool]), list: PropTypes.oneOfType([ImmutablePropTypes.map, PropTypes.bool]),
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
@ -69,7 +68,7 @@ class ListTimeline extends React.PureComponent {
} }
handleDeleteClick = () => { handleDeleteClick = () => {
const { dispatch, columnId, intl } = this.props; const { dispatch, intl } = this.props;
const { id } = this.props.params; const { id } = this.props.params;
dispatch(openModal('CONFIRM', { dispatch(openModal('CONFIRM', {
@ -77,18 +76,13 @@ class ListTimeline extends React.PureComponent {
confirm: intl.formatMessage(messages.deleteConfirm), confirm: intl.formatMessage(messages.deleteConfirm),
onConfirm: () => { onConfirm: () => {
dispatch(deleteList(id)); dispatch(deleteList(id));
this.context.router.history.push('/lists');
if (!!columnId) {
//
} else {
this.context.router.history.push('/lists');
}
}, },
})); }));
} }
render () { render () {
const { hasUnread, columnId, list } = this.props; const { hasUnread, list } = this.props;
const { id } = this.props.params; const { id } = this.props.params;
const title = list ? list.get('title') : id; const title = list ? list.get('title') : id;
@ -126,7 +120,7 @@ class ListTimeline extends React.PureComponent {
</ColumnHeader> </ColumnHeader>
<StatusListContainer <StatusListContainer
scrollKey={`list_timeline-${columnId}`} scrollKey='list_timeline'
timelineId={`list:${id}`} timelineId={`list:${id}`}
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.list' defaultMessage='There is nothing in this list yet. When members of this list post new statuses, they will appear here.' />} emptyMessage={<FormattedMessage id='empty_column.list' defaultMessage='There is nothing in this list yet. When members of this list post new statuses, they will appear here.' />}

View File

@ -47,7 +47,6 @@ export default @connect(mapStateToProps)
class Notifications extends React.PureComponent { class Notifications extends React.PureComponent {
static propTypes = { static propTypes = {
columnId: PropTypes.string,
notifications: ImmutablePropTypes.list.isRequired, notifications: ImmutablePropTypes.list.isRequired,
showFilterBar: PropTypes.bool.isRequired, showFilterBar: PropTypes.bool.isRequired,
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
@ -150,7 +149,7 @@ class Notifications extends React.PureComponent {
const scrollContainer = ( const scrollContainer = (
<ScrollableList <ScrollableList
scrollKey={`notifications-${columnId}`} scrollKey='notifications'
isLoading={isLoading} isLoading={isLoading}
showLoading={isLoading && notifications.size === 0} showLoading={isLoading && notifications.size === 0}
hasMore={hasMore} hasMore={hasMore}

View File

@ -1,26 +1,15 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ColumnSettings from '../../community_timeline/components/column_settings'; import ColumnSettings from '../../community_timeline/components/column_settings';
import { changeSetting } from '../../../actions/settings'; import { changeSetting } from '../../../actions/settings';
import { changeColumnParams } from '../../../actions/columns';
const mapStateToProps = (state, { columnId }) => { const mapStateToProps = state => ({
const uuid = columnId; settings: state.getIn(['settings', 'public']),
const columns = state.getIn(['settings', 'columns']); });
const index = columns.findIndex(c => c.get('uuid') === uuid);
return { const mapDispatchToProps = dispatch => {
settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'public']),
};
};
const mapDispatchToProps = (dispatch, { columnId }) => {
return { return {
onChange (key, checked) { onChange (key, checked) {
if (columnId) { dispatch(changeSetting(['public', ...key], checked));
dispatch(changeColumnParams(columnId, key, checked));
} else {
dispatch(changeSetting(['public', ...key], checked));
}
}, },
}; };
}; };

View File

@ -13,14 +13,12 @@ const messages = defineMessages({
title: { id: 'column.public', defaultMessage: 'Federated timeline' }, title: { id: 'column.public', defaultMessage: 'Federated timeline' },
}); });
const mapStateToProps = (state, { onlyMedia, columnId }) => { const mapStateToProps = (state, { onlyMedia }) => {
const uuid = columnId;
const columns = state.getIn(['settings', 'columns']); const columns = state.getIn(['settings', 'columns']);
const index = columns.findIndex(c => c.get('uuid') === uuid);
return { return {
hasUnread: state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`, 'unread']) > 0, 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']), onlyMedia: state.getIn(['settings', 'public', 'other', 'onlyMedia']),
}; };
}; };
@ -39,7 +37,6 @@ class PublicTimeline extends React.PureComponent {
static propTypes = { static propTypes = {
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
columnId: PropTypes.string,
hasUnread: PropTypes.bool, hasUnread: PropTypes.bool,
onlyMedia: PropTypes.bool, onlyMedia: PropTypes.bool,
}; };
@ -80,13 +77,13 @@ class PublicTimeline extends React.PureComponent {
return ( return (
<Column label={intl.formatMessage(messages.title)}> <Column label={intl.formatMessage(messages.title)}>
<ColumnHeader icon='globe' active={hasUnread} title={intl.formatMessage(messages.title)}> <ColumnHeader icon='globe' active={hasUnread} title={intl.formatMessage(messages.title)}>
<ColumnSettingsContainer columnId={columnId} /> <ColumnSettingsContainer/>
</ColumnHeader> </ColumnHeader>
<StatusListContainer <StatusListContainer
timelineId={`public${onlyMedia ? ':media' : ''}`} timelineId={`public${onlyMedia ? ':media' : ''}`}
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
scrollKey={`public_timeline-${columnId}`} scrollKey='public_timeline'
emptyMessage={<FormattedMessage id='empty_column.public' defaultMessage='There is nothing here! Write something publicly, or manually follow users from other servers to fill it up' />} emptyMessage={<FormattedMessage id='empty_column.public' defaultMessage='There is nothing here! Write something publicly, or manually follow users from other servers to fill it up' />}
/> />
</Column> </Column>