kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Turn some pages into modals
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>strip-front-mentions
rodzic
6e7ef333b8
commit
46ca470f01
|
@ -1,15 +1,35 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { FormattedMessage, injectIntl } from 'react-intl';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Link } from 'react-router-dom';
|
||||
import HoverRefWrapper from 'soapbox/components/hover_ref_wrapper';
|
||||
import { openModal } from 'soapbox/actions/modal';
|
||||
|
||||
export default @injectIntl
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onOpenMentionsModal(username, statusId) {
|
||||
dispatch(openModal('MENTIONS', {
|
||||
username,
|
||||
statusId,
|
||||
}));
|
||||
},
|
||||
});
|
||||
|
||||
export default @connect(null, mapDispatchToProps)
|
||||
@injectIntl
|
||||
class StatusReplyMentions extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
status: ImmutablePropTypes.map.isRequired,
|
||||
onOpenMentionsModal: PropTypes.func,
|
||||
}
|
||||
|
||||
handleOpenMentionsModal = () => {
|
||||
const { status, onOpenMentionsModal } = this.props;
|
||||
|
||||
onOpenMentionsModal(status.getIn(['account', 'acct']), status.get('id'));
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -54,6 +74,7 @@ class StatusReplyMentions extends ImmutablePureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// The typical case with a reply-to and a list of mentions.
|
||||
return (
|
||||
<div className='reply-mentions'>
|
||||
|
@ -68,9 +89,13 @@ class StatusReplyMentions extends ImmutablePureComponent {
|
|||
{' '}
|
||||
</>)),
|
||||
more: to.size > 2 && (
|
||||
<Link to={`/@${status.getIn(['account', 'acct'])}/posts/${status.get('id')}/mentions`}>
|
||||
<a
|
||||
href='#'
|
||||
onClick={this.handleOpenMentionsModal}
|
||||
>
|
||||
|
||||
<FormattedMessage id='reply_mentions.more' defaultMessage='and {count} more' values={{ count: to.size - 2 }} />
|
||||
</Link>
|
||||
</a>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import LoadingIndicator from '../../components/loading_indicator';
|
||||
import { fetchFavourites } from '../../actions/interactions';
|
||||
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
|
||||
import AccountContainer from '../../containers/account_container';
|
||||
import Column from '../ui/components/column';
|
||||
import ScrollableList from '../../components/scrollable_list';
|
||||
|
||||
const messages = defineMessages({
|
||||
heading: { id: 'column.favourites', defaultMessage: 'Likes' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, props) => ({
|
||||
accountIds: state.getIn(['user_lists', 'favourited_by', props.params.statusId]),
|
||||
});
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class Favourites extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
intl: PropTypes.object.isRequired,
|
||||
params: PropTypes.object.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
accountIds: ImmutablePropTypes.orderedSet,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.props.dispatch(fetchFavourites(this.props.params.statusId));
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { statusId } = this.props.params;
|
||||
const { prevStatusId } = prevProps.params;
|
||||
|
||||
if (statusId !== prevStatusId && statusId) {
|
||||
this.props.dispatch(fetchFavourites(statusId));
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { intl, accountIds } = this.props;
|
||||
|
||||
if (!accountIds) {
|
||||
return (
|
||||
<Column>
|
||||
<LoadingIndicator />
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
const emptyMessage = <FormattedMessage id='empty_column.favourites' defaultMessage='No one has liked this post yet. When someone does, they will show up here.' />;
|
||||
|
||||
return (
|
||||
<Column heading={intl.formatMessage(messages.heading)}>
|
||||
<ScrollableList
|
||||
scrollKey='favourites'
|
||||
emptyMessage={emptyMessage}
|
||||
>
|
||||
{accountIds.map(id =>
|
||||
<AccountContainer key={id} id={id} withNote={false} />,
|
||||
)}
|
||||
</ScrollableList>
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import LoadingIndicator from '../../components/loading_indicator';
|
||||
import MissingIndicator from '../../components/missing_indicator';
|
||||
import { fetchStatus } from '../../actions/statuses';
|
||||
import { injectIntl, defineMessages } from 'react-intl';
|
||||
import AccountContainer from '../../containers/account_container';
|
||||
import Column from '../ui/components/column';
|
||||
import ScrollableList from '../../components/scrollable_list';
|
||||
import { makeGetStatus } from '../../selectors';
|
||||
|
||||
const messages = defineMessages({
|
||||
heading: { id: 'column.mentions', defaultMessage: 'Mentions' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
const getStatus = makeGetStatus();
|
||||
const status = getStatus(state, {
|
||||
id: props.params.statusId,
|
||||
username: props.params.username,
|
||||
});
|
||||
|
||||
return {
|
||||
status,
|
||||
accountIds: status ? ImmutableOrderedSet(status.get('mentions').map(m => m.get('id'))) : null,
|
||||
};
|
||||
};
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class Mentions extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
intl: PropTypes.object.isRequired,
|
||||
params: PropTypes.object.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
accountIds: ImmutablePropTypes.orderedSet,
|
||||
status: ImmutablePropTypes.map,
|
||||
};
|
||||
|
||||
fetchData = () => {
|
||||
const { dispatch, params } = this.props;
|
||||
const { statusId } = params;
|
||||
|
||||
dispatch(fetchStatus(statusId));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { params } = this.props;
|
||||
|
||||
if (params.statusId !== prevProps.params.statusId) {
|
||||
this.fetchData();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { intl, accountIds, status } = this.props;
|
||||
|
||||
if (!accountIds) {
|
||||
return (
|
||||
<Column>
|
||||
<LoadingIndicator />
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
return (
|
||||
<Column>
|
||||
<MissingIndicator />
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Column heading={intl.formatMessage(messages.heading)}>
|
||||
<ScrollableList
|
||||
scrollKey='reblogs'
|
||||
>
|
||||
{accountIds.map(id =>
|
||||
<AccountContainer key={id} id={id} withNote={false} />,
|
||||
)}
|
||||
</ScrollableList>
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
|
||||
import LoadingIndicator from '../../components/loading_indicator';
|
||||
import MissingIndicator from '../../components/missing_indicator';
|
||||
import { fetchFavourites, fetchReactions } from '../../actions/interactions';
|
||||
import { fetchStatus } from '../../actions/statuses';
|
||||
import AccountContainer from '../../containers/account_container';
|
||||
import Column from '../ui/components/column';
|
||||
import ScrollableList from '../../components/scrollable_list';
|
||||
import { makeGetStatus } from '../../selectors';
|
||||
|
||||
const messages = defineMessages({
|
||||
heading: { id: 'column.reactions', defaultMessage: 'Reactions' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
const getStatus = makeGetStatus();
|
||||
const status = getStatus(state, {
|
||||
id: props.params.statusId,
|
||||
username: props.params.username,
|
||||
});
|
||||
|
||||
const favourites = state.getIn(['user_lists', 'favourited_by', props.params.statusId]);
|
||||
const reactions = state.getIn(['user_lists', 'reactions', props.params.statusId]);
|
||||
const allReactions = favourites && reactions && ImmutableOrderedSet(favourites ? [{ accounts: favourites, count: favourites.size, name: '👍' }] : []).union(reactions || []);
|
||||
|
||||
return {
|
||||
status,
|
||||
reactions: allReactions,
|
||||
accounts: allReactions && (props.params.reaction
|
||||
? allReactions.find(reaction => reaction.name === props.params.reaction).accounts.map(account => ({ id: account, reaction: props.params.reaction }))
|
||||
: allReactions.map(reaction => reaction.accounts.map(account => ({ id: account, reaction: reaction.name }))).flatten()),
|
||||
};
|
||||
};
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class Reactions extends ImmutablePureComponent {
|
||||
|
||||
static contextTypes = {
|
||||
router: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
params: PropTypes.object.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
reactions: ImmutablePropTypes.orderedSet,
|
||||
accounts: ImmutablePropTypes.orderedSet,
|
||||
status: ImmutablePropTypes.map,
|
||||
};
|
||||
|
||||
fetchData = () => {
|
||||
const { dispatch, params } = this.props;
|
||||
const { statusId } = params;
|
||||
|
||||
dispatch(fetchFavourites(statusId));
|
||||
dispatch(fetchReactions(statusId));
|
||||
dispatch(fetchStatus(statusId));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { params } = this.props;
|
||||
|
||||
if (params.statusId !== prevProps.params.statusId) {
|
||||
this.fetchData();
|
||||
}
|
||||
}
|
||||
|
||||
handleFilterChange = (reaction) => () => {
|
||||
const { params } = this.props;
|
||||
const { username, statusId } = params;
|
||||
|
||||
this.context.router.history.replace(`/@${username}/posts/${statusId}/reactions/${reaction}`);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { intl, params, reactions, accounts, status } = this.props;
|
||||
|
||||
if (!accounts) {
|
||||
return (
|
||||
<Column>
|
||||
<LoadingIndicator />
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
return (
|
||||
<Column>
|
||||
<MissingIndicator />
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
const emptyMessage = <FormattedMessage id='status.reactions.empty' defaultMessage='No one has reacted to this post yet. When someone does, they will show up here.' />;
|
||||
|
||||
return (
|
||||
<Column heading={intl.formatMessage(messages.heading)}>
|
||||
{
|
||||
reactions.size > 0 && (
|
||||
<div className='reaction__filter-bar'>
|
||||
<button className={!params.reaction ? 'active' : ''} onClick={this.handleFilterChange('')}>All</button>
|
||||
{reactions?.filter(reaction => reaction.count).map(reaction => <button key={reaction.name} className={params.reaction === reaction.name ? 'active' : ''} onClick={this.handleFilterChange(reaction.name)}>{reaction.name} {reaction.count}</button>)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<ScrollableList
|
||||
scrollKey='reactions'
|
||||
emptyMessage={emptyMessage}
|
||||
>
|
||||
{accounts.map((account) =>
|
||||
<AccountContainer key={`${account.id}-${account.reaction}`} id={account.id} withNote={false} reaction={account.reaction} />,
|
||||
)}
|
||||
</ScrollableList>
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import LoadingIndicator from '../../components/loading_indicator';
|
||||
import MissingIndicator from '../../components/missing_indicator';
|
||||
import { fetchReblogs } from '../../actions/interactions';
|
||||
import { fetchStatus } from '../../actions/statuses';
|
||||
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
|
||||
import AccountContainer from '../../containers/account_container';
|
||||
import Column from '../ui/components/column';
|
||||
import ScrollableList from '../../components/scrollable_list';
|
||||
import { makeGetStatus } from '../../selectors';
|
||||
|
||||
const messages = defineMessages({
|
||||
heading: { id: 'column.reblogs', defaultMessage: 'Reposts' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
const getStatus = makeGetStatus();
|
||||
const status = getStatus(state, {
|
||||
id: props.params.statusId,
|
||||
username: props.params.username,
|
||||
});
|
||||
|
||||
return {
|
||||
status,
|
||||
accountIds: state.getIn(['user_lists', 'reblogged_by', props.params.statusId]),
|
||||
};
|
||||
};
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class Reblogs extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
intl: PropTypes.object.isRequired,
|
||||
params: PropTypes.object.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
accountIds: ImmutablePropTypes.orderedSet,
|
||||
status: ImmutablePropTypes.map,
|
||||
};
|
||||
|
||||
fetchData = () => {
|
||||
const { dispatch, params } = this.props;
|
||||
const { statusId } = params;
|
||||
|
||||
dispatch(fetchReblogs(statusId));
|
||||
dispatch(fetchStatus(statusId));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { params } = this.props;
|
||||
|
||||
if (params.statusId !== prevProps.params.statusId) {
|
||||
this.fetchData();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { intl, accountIds, status } = this.props;
|
||||
|
||||
if (!accountIds) {
|
||||
return (
|
||||
<Column>
|
||||
<LoadingIndicator />
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
return (
|
||||
<Column>
|
||||
<MissingIndicator />
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
const emptyMessage = <FormattedMessage id='status.reblogs.empty' defaultMessage='No one has reposted this post yet. When someone does, they will show up here.' />;
|
||||
|
||||
return (
|
||||
<Column heading={intl.formatMessage(messages.heading)}>
|
||||
<ScrollableList
|
||||
scrollKey='reblogs'
|
||||
emptyMessage={emptyMessage}
|
||||
>
|
||||
{accountIds.map(id =>
|
||||
<AccountContainer key={id} id={id} withNote={false} />,
|
||||
)}
|
||||
</ScrollableList>
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -8,9 +8,9 @@ import emojify from 'soapbox/features/emoji/emoji';
|
|||
import { reduceEmoji } from 'soapbox/utils/emoji_reacts';
|
||||
import SoapboxPropTypes from 'soapbox/utils/soapbox_prop_types';
|
||||
import { getFeatures } from 'soapbox/utils/features';
|
||||
import { Link } from 'react-router-dom';
|
||||
import Icon from 'soapbox/components/icon';
|
||||
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
||||
import { openModal } from 'soapbox/actions/modal';
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const instance = state.get('instance');
|
||||
|
@ -21,7 +21,29 @@ const mapStateToProps = state => {
|
|||
};
|
||||
};
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onOpenReblogsModal(username, statusId) {
|
||||
dispatch(openModal('REBLOGS', {
|
||||
username,
|
||||
statusId,
|
||||
}));
|
||||
},
|
||||
onOpenFavouritesModal(username, statusId) {
|
||||
dispatch(openModal('FAVOURITES', {
|
||||
username,
|
||||
statusId,
|
||||
}));
|
||||
},
|
||||
onOpenReactionsModal(username, statusId, reaction) {
|
||||
dispatch(openModal('REACTIONS', {
|
||||
username,
|
||||
statusId,
|
||||
reaction,
|
||||
}));
|
||||
},
|
||||
});
|
||||
|
||||
export default @connect(mapStateToProps, mapDispatchToProps)
|
||||
class StatusInteractionBar extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
|
@ -29,6 +51,8 @@ class StatusInteractionBar extends ImmutablePureComponent {
|
|||
me: SoapboxPropTypes.me,
|
||||
allowedEmoji: ImmutablePropTypes.list,
|
||||
features: PropTypes.object.isRequired,
|
||||
onOpenReblogsModal: PropTypes.func,
|
||||
onOpenReactionsModal: PropTypes.func,
|
||||
}
|
||||
|
||||
getNormalizedReacts = () => {
|
||||
|
@ -41,22 +65,39 @@ class StatusInteractionBar extends ImmutablePureComponent {
|
|||
).reverse();
|
||||
}
|
||||
|
||||
handleOpenReblogsModal = () => {
|
||||
const { status, onOpenReblogsModal } = this.props;
|
||||
|
||||
onOpenReblogsModal(status.getIn(['account', 'acct']), status.get('id'));
|
||||
}
|
||||
|
||||
getReposts = () => {
|
||||
const { status } = this.props;
|
||||
|
||||
if (status.get('reblogs_count')) {
|
||||
return (
|
||||
<Link to={`/@${status.getIn(['account', 'acct'])}/posts/${status.get('id')}/reblogs`} className='emoji-react emoji-react--reblogs'>
|
||||
<a
|
||||
href='#'
|
||||
className='emoji-react emoji-react--reblogs'
|
||||
onClick={this.handleOpenReblogsModal}
|
||||
>
|
||||
<Icon src={require('feather-icons/dist/icons/repeat.svg')} />
|
||||
<span className='emoji-reacts__count'>
|
||||
<FormattedNumber value={status.get('reblogs_count')} />
|
||||
</span>
|
||||
</Link>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
handleOpenFavouritesModal = () => {
|
||||
const { status, onOpenFavouritesModal } = this.props;
|
||||
|
||||
onOpenFavouritesModal(status.getIn(['account', 'acct']), status.get('id'));
|
||||
}
|
||||
|
||||
getFavourites = () => {
|
||||
const { features, status } = this.props;
|
||||
|
||||
|
@ -72,9 +113,13 @@ class StatusInteractionBar extends ImmutablePureComponent {
|
|||
|
||||
if (features.exposableReactions) {
|
||||
return (
|
||||
<Link to={`/@${status.getIn(['account', 'acct'])}/posts/${status.get('id')}/likes`} className='emoji-react emoji-react--favourites'>
|
||||
<a
|
||||
href='#'
|
||||
className='emoji-react emoji-react--favourites'
|
||||
onClick={this.handleOpenFavouritesModal}
|
||||
>
|
||||
{favourites}
|
||||
</Link>
|
||||
</a>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
|
@ -88,8 +133,14 @@ class StatusInteractionBar extends ImmutablePureComponent {
|
|||
return '';
|
||||
}
|
||||
|
||||
handleOpenReactionsModal = (reaction) => () => {
|
||||
const { status, onOpenReactionsModal } = this.props;
|
||||
|
||||
onOpenReactionsModal(status.getIn(['account', 'acct']), status.get('id'), reaction.get('name'));
|
||||
}
|
||||
|
||||
getEmojiReacts = () => {
|
||||
const { status, features } = this.props;
|
||||
const { features } = this.props;
|
||||
|
||||
const emojiReacts = this.getNormalizedReacts();
|
||||
const count = emojiReacts.reduce((acc, cur) => (
|
||||
|
@ -112,7 +163,16 @@ class StatusInteractionBar extends ImmutablePureComponent {
|
|||
);
|
||||
|
||||
if (features.exposableReactions) {
|
||||
return <Link to={`/@${status.getIn(['account', 'acct'])}/posts/${status.get('id')}/reactions/${e.get('name')}`} className='emoji-react' key={i}>{emojiReact}</Link>;
|
||||
return (
|
||||
<a
|
||||
href='#'
|
||||
className='emoji-react'
|
||||
key={i}
|
||||
onClick={this.handleOpenReactionsModal(e)}
|
||||
>
|
||||
{emojiReact}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
return <span className='emoji-react' key={i}>{emojiReact}</span>;
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';
|
||||
import IconButton from 'soapbox/components/icon_button';
|
||||
import LoadingIndicator from 'soapbox/components/loading_indicator';
|
||||
import AccountContainer from 'soapbox/containers/account_container';
|
||||
import ScrollableList from 'soapbox/components/scrollable_list';
|
||||
import { fetchFavourites } from 'soapbox/actions/interactions';
|
||||
|
||||
const messages = defineMessages({
|
||||
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
return {
|
||||
accountIds: state.getIn(['user_lists', 'favourited_by', props.statusId]),
|
||||
};
|
||||
};
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class FavouritesModal extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
statusId: PropTypes.string.isRequired,
|
||||
username: PropTypes.string.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
accountIds: ImmutablePropTypes.orderedSet,
|
||||
};
|
||||
|
||||
fetchData = () => {
|
||||
const { dispatch, statusId } = this.props;
|
||||
|
||||
dispatch(fetchFavourites(statusId));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
onClickClose = () => {
|
||||
this.props.onClose('FAVOURITES');
|
||||
};
|
||||
|
||||
render() {
|
||||
const { intl, accountIds } = this.props;
|
||||
|
||||
let body;
|
||||
|
||||
if (!accountIds) {
|
||||
body = <LoadingIndicator />;
|
||||
} else {
|
||||
const emptyMessage = <FormattedMessage id='empty_column.favourites' defaultMessage='No one has liked this post yet. When someone does, they will show up here.' />;
|
||||
|
||||
body = (
|
||||
<ScrollableList
|
||||
scrollKey='favourites'
|
||||
emptyMessage={emptyMessage}
|
||||
>
|
||||
{accountIds.map(id =>
|
||||
<AccountContainer key={id} id={id} withNote={false} />,
|
||||
)}
|
||||
</ScrollableList>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal reactions-modal'>
|
||||
<div className='compose-modal__header'>
|
||||
<h3 className='compose-modal__header__title'>
|
||||
<FormattedMessage id='column.favourites' defaultMessage='likes' />
|
||||
</h3>
|
||||
<IconButton
|
||||
className='compose-modal__close'
|
||||
title={intl.formatMessage(messages.close)}
|
||||
src={require('@tabler/icons/icons/x.svg')}
|
||||
onClick={this.onClickClose} size={20}
|
||||
/>
|
||||
</div>
|
||||
{body}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
|
||||
import IconButton from 'soapbox/components/icon_button';
|
||||
import LoadingIndicator from 'soapbox/components/loading_indicator';
|
||||
import AccountContainer from 'soapbox/containers/account_container';
|
||||
import ScrollableList from 'soapbox/components/scrollable_list';
|
||||
import { makeGetStatus } from 'soapbox/selectors';
|
||||
import { fetchStatus } from 'soapbox/actions/statuses';
|
||||
|
||||
const messages = defineMessages({
|
||||
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
const getStatus = makeGetStatus();
|
||||
const status = getStatus(state, {
|
||||
id: props.statusId,
|
||||
username: props.username,
|
||||
});
|
||||
|
||||
return {
|
||||
accountIds: status ? ImmutableOrderedSet(status.get('mentions').map(m => m.get('id'))) : null,
|
||||
};
|
||||
};
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class MentionsModal extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
statusId: PropTypes.string.isRequired,
|
||||
username: PropTypes.string.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
accountIds: ImmutablePropTypes.orderedSet,
|
||||
};
|
||||
|
||||
fetchData = () => {
|
||||
const { dispatch, statusId } = this.props;
|
||||
|
||||
dispatch(fetchStatus(statusId));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
onClickClose = () => {
|
||||
this.props.onClose('MENTIONS');
|
||||
};
|
||||
|
||||
render() {
|
||||
const { intl, accountIds } = this.props;
|
||||
|
||||
let body;
|
||||
|
||||
if (!accountIds) {
|
||||
body = <LoadingIndicator />;
|
||||
} else {
|
||||
body = (
|
||||
<ScrollableList
|
||||
scrollKey='mentions'
|
||||
>
|
||||
{accountIds.map(id =>
|
||||
<AccountContainer key={id} id={id} withNote={false} />,
|
||||
)}
|
||||
</ScrollableList>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal reactions-modal'>
|
||||
<div className='compose-modal__header'>
|
||||
<h3 className='compose-modal__header__title'>
|
||||
<FormattedMessage id='column.mentions' defaultMessage='Mentions' />
|
||||
</h3>
|
||||
<IconButton
|
||||
className='compose-modal__close'
|
||||
title={intl.formatMessage(messages.close)}
|
||||
src={require('@tabler/icons/icons/x.svg')}
|
||||
onClick={this.onClickClose} size={20}
|
||||
/>
|
||||
</div>
|
||||
{body}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,10 @@ import {
|
|||
UnauthorizedModal,
|
||||
EditFederationModal,
|
||||
ComponentModal,
|
||||
ReactionsModal,
|
||||
FavouritesModal,
|
||||
ReblogsModal,
|
||||
MentionsModal,
|
||||
} from '../../../features/ui/util/async-components';
|
||||
|
||||
const MODAL_COMPONENTS = {
|
||||
|
@ -47,6 +51,10 @@ const MODAL_COMPONENTS = {
|
|||
'CRYPTO_DONATE': CryptoDonateModal,
|
||||
'EDIT_FEDERATION': EditFederationModal,
|
||||
'COMPONENT': ComponentModal,
|
||||
'REBLOGS': ReblogsModal,
|
||||
'FAVOURITES': FavouritesModal,
|
||||
'REACTIONS': ReactionsModal,
|
||||
'MENTIONS': MentionsModal,
|
||||
};
|
||||
|
||||
export default class ModalRoot extends React.PureComponent {
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { List as ImmutableList } from 'immutable';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';
|
||||
import IconButton from 'soapbox/components/icon_button';
|
||||
import LoadingIndicator from 'soapbox/components/loading_indicator';
|
||||
import AccountContainer from 'soapbox/containers/account_container';
|
||||
import ScrollableList from 'soapbox/components/scrollable_list';
|
||||
import { fetchFavourites, fetchReactions } from 'soapbox/actions/interactions';
|
||||
|
||||
const messages = defineMessages({
|
||||
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
|
||||
const favourites = state.getIn(['user_lists', 'favourited_by', props.statusId]);
|
||||
const reactions = state.getIn(['user_lists', 'reactions', props.statusId]);
|
||||
const allReactions = favourites && reactions && ImmutableList(favourites ? [{ accounts: favourites, count: favourites.size, name: '👍' }] : []).concat(reactions || []);
|
||||
|
||||
return {
|
||||
reactions: allReactions,
|
||||
};
|
||||
};
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class ReactionsModal extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
statusId: PropTypes.string.isRequired,
|
||||
username: PropTypes.string.isRequired,
|
||||
reaction: PropTypes.string,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
reactions: ImmutablePropTypes.list,
|
||||
};
|
||||
|
||||
state = {
|
||||
reaction: this.props.reaction,
|
||||
}
|
||||
|
||||
fetchData = () => {
|
||||
const { dispatch, statusId } = this.props;
|
||||
|
||||
dispatch(fetchFavourites(statusId));
|
||||
dispatch(fetchReactions(statusId));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
onClickClose = () => {
|
||||
this.props.onClose('REACTIONS');
|
||||
};
|
||||
|
||||
handleFilterChange = (reaction) => () => {
|
||||
this.setState({ reaction });
|
||||
};
|
||||
|
||||
render() {
|
||||
const { intl, reactions } = this.props;
|
||||
const { reaction } = this.state;
|
||||
|
||||
const accounts = reactions && (reaction
|
||||
? reactions.find(reaction => reaction.name === this.state.reaction).accounts.map(account => ({ id: account, reaction: this.state.reaction }))
|
||||
: reactions.map(reaction => reaction.accounts.map(account => ({ id: account, reaction: reaction.name }))).flatten());
|
||||
|
||||
let body;
|
||||
|
||||
if (!accounts) {
|
||||
body = <LoadingIndicator />;
|
||||
} else {
|
||||
const emptyMessage = <FormattedMessage id='status.reactions.empty' defaultMessage='No one has reacted to this post yet. When someone does, they will show up here.' />;
|
||||
|
||||
body = (<>
|
||||
{
|
||||
reactions.size > 0 && (
|
||||
<div className='reaction__filter-bar'>
|
||||
<button className={!reaction ? 'active' : ''} onClick={this.handleFilterChange('')}>All</button>
|
||||
{reactions?.filter(reaction => reaction.count).map(reaction => <button key={reaction.name} className={this.state.reaction === reaction.name ? 'active' : ''} onClick={this.handleFilterChange(reaction.name)}>{reaction.name} {reaction.count}</button>)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<ScrollableList
|
||||
scrollKey='reactions'
|
||||
emptyMessage={emptyMessage}
|
||||
>
|
||||
{accounts.map((account) =>
|
||||
<AccountContainer key={`${account.id}-${account.reaction}`} id={account.id} withNote={false} reaction={account.reaction} />,
|
||||
)}
|
||||
</ScrollableList>
|
||||
</>);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal reactions-modal'>
|
||||
<div className='compose-modal__header'>
|
||||
<h3 className='compose-modal__header__title'>
|
||||
<FormattedMessage id='column.reactions' defaultMessage='Reactions' />
|
||||
</h3>
|
||||
<IconButton
|
||||
className='compose-modal__close'
|
||||
title={intl.formatMessage(messages.close)}
|
||||
src={require('@tabler/icons/icons/x.svg')}
|
||||
onClick={this.onClickClose} size={20}
|
||||
/>
|
||||
</div>
|
||||
{body}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';
|
||||
import IconButton from 'soapbox/components/icon_button';
|
||||
import LoadingIndicator from 'soapbox/components/loading_indicator';
|
||||
import AccountContainer from 'soapbox/containers/account_container';
|
||||
import ScrollableList from 'soapbox/components/scrollable_list';
|
||||
import { fetchReblogs } from 'soapbox/actions/interactions';
|
||||
import { fetchStatus } from 'soapbox/actions/statuses';
|
||||
|
||||
const messages = defineMessages({
|
||||
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
return {
|
||||
accountIds: state.getIn(['user_lists', 'reblogged_by', props.statusId]),
|
||||
};
|
||||
};
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class ReblogsModal extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
statusId: PropTypes.string.isRequired,
|
||||
username: PropTypes.string.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
accountIds: ImmutablePropTypes.orderedSet,
|
||||
};
|
||||
|
||||
fetchData = () => {
|
||||
const { dispatch, statusId } = this.props;
|
||||
|
||||
dispatch(fetchReblogs(statusId));
|
||||
dispatch(fetchStatus(statusId));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
onClickClose = () => {
|
||||
this.props.onClose('REBLOGS');
|
||||
};
|
||||
|
||||
render() {
|
||||
const { intl, accountIds } = this.props;
|
||||
|
||||
let body;
|
||||
|
||||
if (!accountIds) {
|
||||
body = <LoadingIndicator />;
|
||||
} else {
|
||||
const emptyMessage = <FormattedMessage id='status.reblogs.empty' defaultMessage='No one has reposted this post yet. When someone does, they will show up here.' />;
|
||||
|
||||
body = (
|
||||
<ScrollableList
|
||||
scrollKey='reblogs'
|
||||
emptyMessage={emptyMessage}
|
||||
>
|
||||
{accountIds.map(id =>
|
||||
<AccountContainer key={id} id={id} withNote={false} />,
|
||||
)}
|
||||
</ScrollableList>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal reactions-modal'>
|
||||
<div className='compose-modal__header'>
|
||||
<h3 className='compose-modal__header__title'>
|
||||
<FormattedMessage id='column.reblogs' defaultMessage='Reposts' />
|
||||
</h3>
|
||||
<IconButton
|
||||
className='compose-modal__close'
|
||||
title={intl.formatMessage(messages.close)}
|
||||
src={require('@tabler/icons/icons/x.svg')}
|
||||
onClick={this.onClickClose} size={20}
|
||||
/>
|
||||
</div>
|
||||
{body}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -56,10 +56,6 @@ import {
|
|||
HomeTimeline,
|
||||
Followers,
|
||||
Following,
|
||||
Reblogs,
|
||||
Reactions,
|
||||
Mentions,
|
||||
Favourites,
|
||||
DirectTimeline,
|
||||
Conversations,
|
||||
HashtagTimeline,
|
||||
|
@ -298,10 +294,6 @@ class SwitchingColumnsArea extends React.PureComponent {
|
|||
<WrappedRoute path='/@:username/favorites' component={FavouritedStatuses} page={ProfilePage} content={children} />
|
||||
<WrappedRoute path='/@:username/pins' component={PinnedStatuses} page={ProfilePage} content={children} />
|
||||
<WrappedRoute path='/@:username/posts/:statusId' publicRoute exact page={StatusPage} component={Status} content={children} />
|
||||
<WrappedRoute path='/@:username/posts/:statusId/reblogs' page={DefaultPage} component={Reblogs} content={children} />
|
||||
<WrappedRoute path='/@:username/posts/:statusId/likes' page={DefaultPage} component={Favourites} content={children} />
|
||||
<WrappedRoute path='/@:username/posts/:statusId/reactions/:reaction?' page={DefaultPage} component={Reactions} content={children} />
|
||||
<WrappedRoute path='/@:username/posts/:statusId/mentions' page={DefaultPage} component={Mentions} content={children} />
|
||||
<Redirect from='/@:username/:statusId' to='/@:username/posts/:statusId' />
|
||||
|
||||
<WrappedRoute path='/statuses/new' page={DefaultPage} component={NewStatus} content={children} exact />
|
||||
|
|
|
@ -94,22 +94,6 @@ export function Following() {
|
|||
return import(/* webpackChunkName: "features/following" */'../../following');
|
||||
}
|
||||
|
||||
export function Reblogs() {
|
||||
return import(/* webpackChunkName: "features/reblogs" */'../../reblogs');
|
||||
}
|
||||
|
||||
export function Reactions() {
|
||||
return import(/* webpackChunkName: "features/reactions" */'../../reactions');
|
||||
}
|
||||
|
||||
export function Mentions() {
|
||||
return import(/* webpackChunkName: "features/mentions" */'../../mentions');
|
||||
}
|
||||
|
||||
export function Favourites() {
|
||||
return import(/* webpackChunkName: "features/favourites" */'../../favourites');
|
||||
}
|
||||
|
||||
export function FollowRequests() {
|
||||
return import(/* webpackChunkName: "features/follow_requests" */'../../follow_requests');
|
||||
}
|
||||
|
@ -214,6 +198,22 @@ export function ComponentModal() {
|
|||
return import(/* webpackChunkName: "features/ui" */'../components/component_modal');
|
||||
}
|
||||
|
||||
export function ReblogsModal() {
|
||||
return import(/* webpackChunkName: "features/ui" */'../components/reblogs_modal');
|
||||
}
|
||||
|
||||
export function FavouritesModal() {
|
||||
return import(/* webpackChunkName: "features/ui" */'../components/favourites_modal');
|
||||
}
|
||||
|
||||
export function ReactionsModal() {
|
||||
return import(/* webpackChunkName: "features/ui" */'../components/reactions_modal');
|
||||
}
|
||||
|
||||
export function MentionsModal() {
|
||||
return import(/* webpackChunkName: "features/ui" */'../components/mentions_modal');
|
||||
}
|
||||
|
||||
export function ListEditor() {
|
||||
return import(/* webpackChunkName: "features/list_editor" */'../../list_editor');
|
||||
}
|
||||
|
|
|
@ -339,7 +339,10 @@
|
|||
.confirmation-modal,
|
||||
.report-modal,
|
||||
.actions-modal,
|
||||
.mute-modal {
|
||||
.mute-modal,
|
||||
.reactions-modal,
|
||||
.reblogs-modal,
|
||||
.mentions-modal {
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
|
@ -385,6 +388,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
.reactions-modal,
|
||||
.reblogs-modal,
|
||||
.mentions-modal {
|
||||
height: 80vh;
|
||||
|
||||
.slist {
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.boost-modal__container {
|
||||
overflow-x: scroll;
|
||||
padding: 10px;
|
||||
|
|
Ładowanie…
Reference in New Issue