mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-24 17:14:15 -05:00
[Glitch] Change column params on pinned timeline
Port 06252ec71e
to glitch-soc
This commit is contained in:
parent
c03cbb9471
commit
593f88acb1
@ -1,8 +1,9 @@
|
|||||||
import { saveSettings } from './settings';
|
import { saveSettings } from './settings';
|
||||||
|
|
||||||
export const COLUMN_ADD = 'COLUMN_ADD';
|
export const COLUMN_ADD = 'COLUMN_ADD';
|
||||||
export const COLUMN_REMOVE = 'COLUMN_REMOVE';
|
export const COLUMN_REMOVE = 'COLUMN_REMOVE';
|
||||||
export const COLUMN_MOVE = 'COLUMN_MOVE';
|
export const COLUMN_MOVE = 'COLUMN_MOVE';
|
||||||
|
export const COLUMN_PARAMS_CHANGE = 'COLUMN_PARAMS_CHANGE';
|
||||||
|
|
||||||
export function addColumn(id, params) {
|
export function addColumn(id, params) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
@ -38,3 +39,15 @@ export function moveColumn(uuid, direction) {
|
|||||||
dispatch(saveSettings());
|
dispatch(saveSettings());
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function changeColumnParams(uuid, params) {
|
||||||
|
return dispatch => {
|
||||||
|
dispatch({
|
||||||
|
type: COLUMN_PARAMS_CHANGE,
|
||||||
|
uuid,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch(saveSettings());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { NavLink, Link } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
import Column from 'flavours/glitch/components/column';
|
import Column from 'flavours/glitch/components/column';
|
||||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
import { expandCommunityTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandCommunityTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
import { addColumn, removeColumn, moveColumn, changeColumnParams } from 'flavours/glitch/actions/columns';
|
||||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||||
import { connectCommunityStream } from 'flavours/glitch/actions/streaming';
|
import { connectCommunityStream } from 'flavours/glitch/actions/streaming';
|
||||||
|
|
||||||
@ -62,6 +62,16 @@ export default class CommunityTimeline extends React.PureComponent {
|
|||||||
this.disconnect = dispatch(connectCommunityStream({ onlyMedia }));
|
this.disconnect = dispatch(connectCommunityStream({ onlyMedia }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate (prevProps) {
|
||||||
|
if (prevProps.onlyMedia !== this.props.onlyMedia) {
|
||||||
|
const { dispatch, onlyMedia } = this.props;
|
||||||
|
|
||||||
|
this.disconnect();
|
||||||
|
dispatch(expandCommunityTimeline({ onlyMedia }));
|
||||||
|
this.disconnect = dispatch(connectCommunityStream({ onlyMedia }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
if (this.disconnect) {
|
if (this.disconnect) {
|
||||||
this.disconnect();
|
this.disconnect();
|
||||||
@ -79,14 +89,31 @@ export default class CommunityTimeline extends React.PureComponent {
|
|||||||
dispatch(expandCommunityTimeline({ maxId, onlyMedia }));
|
dispatch(expandCommunityTimeline({ maxId, onlyMedia }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldUpdateScroll = (prevRouterProps, { location }) => {
|
||||||
|
return !(location.state && location.state.mastodonModalOpen)
|
||||||
|
}
|
||||||
|
|
||||||
|
handleHeadlineLinkClick = e => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const { columnId, dispatch } = this.props;
|
||||||
|
const onlyMedia = /\/media$/.test(e.currentTarget.href);
|
||||||
|
|
||||||
|
dispatch(changeColumnParams(columnId, { other: { onlyMedia } }));
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props;
|
const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props;
|
||||||
const pinned = !!columnId;
|
const pinned = !!columnId;
|
||||||
|
|
||||||
const headline = pinned ? (
|
const headline = pinned ? (
|
||||||
<div className='community-timeline__section-headline'>
|
<div className='community-timeline__section-headline'>
|
||||||
<Link to='/timelines/public/local' replace className={!onlyMedia ? 'active' : undefined}><FormattedMessage id='timeline.posts' defaultMessage='Toots' /></Link>
|
<a href='/timelines/public/local' className={!onlyMedia ? 'active' : undefined} onClick={this.handleHeadlineLinkClick}>
|
||||||
<Link to='/timelines/public/local/media' replace className={onlyMedia ? 'active' : undefined}><FormattedMessage id='timeline.media' defaultMessage='Media' /></Link>
|
<FormattedMessage id='timeline.posts' defaultMessage='Toots' />
|
||||||
|
</a>
|
||||||
|
<a href='/timelines/public/local/media' className={onlyMedia ? 'active' : undefined} onClick={this.handleHeadlineLinkClick}>
|
||||||
|
<FormattedMessage id='timeline.media' defaultMessage='Media' />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className='community-timeline__section-headline'>
|
<div className='community-timeline__section-headline'>
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { NavLink, Link } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
import Column from 'flavours/glitch/components/column';
|
import Column from 'flavours/glitch/components/column';
|
||||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
import { expandPublicTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandPublicTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
import { addColumn, removeColumn, moveColumn, changeColumnParams } from 'flavours/glitch/actions/columns';
|
||||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||||
import { connectPublicStream } from 'flavours/glitch/actions/streaming';
|
import { connectPublicStream } from 'flavours/glitch/actions/streaming';
|
||||||
|
|
||||||
@ -62,6 +62,16 @@ export default class PublicTimeline extends React.PureComponent {
|
|||||||
this.disconnect = dispatch(connectPublicStream({ onlyMedia }));
|
this.disconnect = dispatch(connectPublicStream({ onlyMedia }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate (prevProps) {
|
||||||
|
if (prevProps.onlyMedia !== this.props.onlyMedia) {
|
||||||
|
const { dispatch, onlyMedia } = this.props;
|
||||||
|
|
||||||
|
this.disconnect();
|
||||||
|
dispatch(expandPublicTimeline({ onlyMedia }));
|
||||||
|
this.disconnect = dispatch(connectPublicStream({ onlyMedia }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
if (this.disconnect) {
|
if (this.disconnect) {
|
||||||
this.disconnect();
|
this.disconnect();
|
||||||
@ -79,14 +89,31 @@ export default class PublicTimeline extends React.PureComponent {
|
|||||||
dispatch(expandPublicTimeline({ maxId, onlyMedia }));
|
dispatch(expandPublicTimeline({ maxId, onlyMedia }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldUpdateScroll = (prevRouterProps, { location }) => {
|
||||||
|
return !(location.state && location.state.mastodonModalOpen)
|
||||||
|
}
|
||||||
|
|
||||||
|
handleHeadlineLinkClick = e => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const { columnId, dispatch } = this.props;
|
||||||
|
const onlyMedia = /\/media$/.test(e.currentTarget.href);
|
||||||
|
|
||||||
|
dispatch(changeColumnParams(columnId, { other: { onlyMedia } }));
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { intl, columnId, hasUnread, multiColumn, onlyMedia } = this.props;
|
const { intl, columnId, hasUnread, multiColumn, onlyMedia } = this.props;
|
||||||
const pinned = !!columnId;
|
const pinned = !!columnId;
|
||||||
|
|
||||||
const headline = pinned ? (
|
const headline = pinned ? (
|
||||||
<div className='public-timeline__section-headline'>
|
<div className='public-timeline__section-headline'>
|
||||||
<Link to='/timelines/public' replace className={!onlyMedia ? 'active' : undefined}><FormattedMessage id='timeline.posts' defaultMessage='Toots' /></Link>
|
<a href='/timelines/public' className={!onlyMedia ? 'active' : undefined} onClick={this.handleHeadlineLinkClick}>
|
||||||
<Link to='/timelines/public/media' replace className={onlyMedia ? 'active' : undefined}><FormattedMessage id='timeline.media' defaultMessage='Media' /></Link>
|
<FormattedMessage id='timeline.posts' defaultMessage='Toots' />
|
||||||
|
</a>
|
||||||
|
<a href='/timelines/public/media' className={onlyMedia ? 'active' : undefined} onClick={this.handleHeadlineLinkClick}>
|
||||||
|
<FormattedMessage id='timeline.media' defaultMessage='Media' />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className='public-timeline__section-headline'>
|
<div className='public-timeline__section-headline'>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { SETTING_CHANGE, SETTING_SAVE } from 'flavours/glitch/actions/settings';
|
import { SETTING_CHANGE, SETTING_SAVE } from 'flavours/glitch/actions/settings';
|
||||||
import { NOTIFICATIONS_FILTER_SET } from 'flavours/glitch/actions/notifications';
|
import { NOTIFICATIONS_FILTER_SET } from 'flavours/glitch/actions/notifications';
|
||||||
import { COLUMN_ADD, COLUMN_REMOVE, COLUMN_MOVE } from 'flavours/glitch/actions/columns';
|
import { COLUMN_ADD, COLUMN_REMOVE, COLUMN_MOVE, COLUMN_PARAMS_CHANGE } from 'flavours/glitch/actions/columns';
|
||||||
import { STORE_HYDRATE } from 'flavours/glitch/actions/store';
|
import { STORE_HYDRATE } from 'flavours/glitch/actions/store';
|
||||||
import { EMOJI_USE } from 'flavours/glitch/actions/emojis';
|
import { EMOJI_USE } from 'flavours/glitch/actions/emojis';
|
||||||
import { LIST_DELETE_SUCCESS, LIST_FETCH_FAIL } from '../actions/lists';
|
import { LIST_DELETE_SUCCESS, LIST_FETCH_FAIL } from '../actions/lists';
|
||||||
@ -98,6 +98,17 @@ const moveColumn = (state, uuid, direction) => {
|
|||||||
.set('saved', false);
|
.set('saved', false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const changeColumnParams = (state, uuid, params) => {
|
||||||
|
const columns = state.get('columns');
|
||||||
|
const index = columns.findIndex(item => item.get('uuid') === uuid);
|
||||||
|
|
||||||
|
const newColumns = columns.update(index, column => column.update('params', () => fromJS(params)));
|
||||||
|
|
||||||
|
return state
|
||||||
|
.set('columns', newColumns)
|
||||||
|
.set('saved', false);
|
||||||
|
};
|
||||||
|
|
||||||
const updateFrequentEmojis = (state, emoji) => state.update('frequentlyUsedEmojis', ImmutableMap(), map => map.update(emoji.id, 0, count => count + 1)).set('saved', false);
|
const updateFrequentEmojis = (state, emoji) => state.update('frequentlyUsedEmojis', ImmutableMap(), map => map.update(emoji.id, 0, count => count + 1)).set('saved', false);
|
||||||
|
|
||||||
const filterDeadListColumns = (state, listId) => state.update('columns', columns => columns.filterNot(column => column.get('id') === 'LIST' && column.get('params').get('id') === listId));
|
const filterDeadListColumns = (state, listId) => state.update('columns', columns => columns.filterNot(column => column.get('id') === 'LIST' && column.get('params').get('id') === listId));
|
||||||
@ -121,6 +132,8 @@ export default function settings(state = initialState, action) {
|
|||||||
.set('saved', false);
|
.set('saved', false);
|
||||||
case COLUMN_MOVE:
|
case COLUMN_MOVE:
|
||||||
return moveColumn(state, action.uuid, action.direction);
|
return moveColumn(state, action.uuid, action.direction);
|
||||||
|
case COLUMN_PARAMS_CHANGE:
|
||||||
|
return changeColumnParams(state, action.uuid, action.params);
|
||||||
case EMOJI_USE:
|
case EMOJI_USE:
|
||||||
return updateFrequentEmojis(state, action.emoji);
|
return updateFrequentEmojis(state, action.emoji);
|
||||||
case SETTING_SAVE:
|
case SETTING_SAVE:
|
||||||
|
Loading…
Reference in New Issue
Block a user