Add lists, favourite domains, favourite hashtags to Getting started

This commit is contained in:
noellabo 2021-04-14 12:21:50 +09:00
parent 7c01b118bf
commit edf71e9cca
6 changed files with 68 additions and 8 deletions

View file

@ -9,10 +9,16 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { me, profile_directory, showTrends, enable_limited_timeline } from '../../initial_state';
import { fetchFollowRequests } from 'mastodon/actions/accounts';
import { fetchLists } from 'mastodon/actions/lists';
import { fetchFavouriteDomains } from 'mastodon/actions/favourite_domains';
import { fetchFavouriteTags } from 'mastodon/actions/favourite_tags';
import { List as ImmutableList } from 'immutable';
import NavigationContainer from '../compose/containers/navigation_container';
import Icon from 'mastodon/components/icon';
import LinkFooter from 'mastodon/features/ui/components/link_footer';
import { getOrderedLists } from 'mastodon/features/ui/components/list_panel';
import { getOrderedDomains } from 'mastodon/features/ui/components/favourite_domain_panel';
import { getOrderedTags } from 'mastodon/features/ui/components/favourite_tag_panel';
import TrendsContainer from './containers/trends_container';
const messages = defineMessages({
@ -42,16 +48,25 @@ const messages = defineMessages({
trends: { id: 'navigation_bar.trends', defaultMessage: 'Trends' },
information_acct: { id: 'navigation_bar.information_acct', defaultMessage: 'Fedibird info' },
hashtag_fedibird: { id: 'navigation_bar.hashtag_fedibird', defaultMessage: 'fedibird' },
lists_subheading: { id: 'column_subheading.lists', defaultMessage: 'Lists' },
favourite_domains_subheading: { id: 'column_subheading.favourite_domains', defaultMessage: 'Favourite domains' },
favourite_tags_subheading: { id: 'column_subheading.favourite_tags', defaultMessage: 'Favourite tags' },
});
const mapStateToProps = state => ({
myAccount: state.getIn(['accounts', me]),
columns: state.getIn(['settings', 'columns']),
unreadFollowRequests: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size,
lists: getOrderedLists(state),
favourite_domains: getOrderedDomains(state),
favourite_tags: getOrderedTags(state),
});
const mapDispatchToProps = dispatch => ({
fetchFollowRequests: () => dispatch(fetchFollowRequests()),
fetchLists: () => dispatch(fetchLists()),
fetchFavouriteDomains: () => dispatch(fetchFavouriteDomains()),
fetchFavouriteTags: () => dispatch(fetchFavouriteTags()),
});
const badgeDisplay = (number, limit) => {
@ -80,12 +95,18 @@ class GettingStarted extends ImmutablePureComponent {
columns: ImmutablePropTypes.list,
multiColumn: PropTypes.bool,
fetchFollowRequests: PropTypes.func.isRequired,
fetchLists: PropTypes.func.isRequired,
fetchFavouriteDomains: PropTypes.func.isRequired,
fetchFavouriteTags: PropTypes.func.isRequired,
unreadFollowRequests: PropTypes.number,
unreadNotifications: PropTypes.number,
lists: ImmutablePropTypes.list,
favourite_domains: ImmutablePropTypes.list,
favourite_tags: ImmutablePropTypes.list,
};
componentDidMount () {
const { fetchFollowRequests, multiColumn } = this.props;
const { fetchFollowRequests, fetchLists, fetchFavouriteDomains, fetchFavouriteTags, multiColumn } = this.props;
if (!multiColumn && window.innerWidth >= NAVIGATION_PANEL_BREAKPOINT) {
this.context.router.history.replace('/timelines/home');
@ -93,11 +114,14 @@ class GettingStarted extends ImmutablePureComponent {
}
fetchFollowRequests();
fetchLists();
fetchFavouriteDomains();
fetchFavouriteTags();
}
render () {
const { intl, myAccount, columns, multiColumn, unreadFollowRequests } = this.props;
const { intl, myAccount, columns, multiColumn, unreadFollowRequests, lists, favourite_domains, favourite_tags } = this.props;
const navItems = [];
let height = (multiColumn) ? 0 : 60;
@ -196,6 +220,36 @@ class GettingStarted extends ImmutablePureComponent {
height += 48*5;
if (lists && !lists.isEmpty()) {
navItems.push(<ColumnSubheading key='header-lists' text={intl.formatMessage(messages.lists_subheading)} />);
height += 34;
lists.map(list => {
navItems.push(<ColumnLink key={`list:${list.get('id')}`} icon='list-ul' text={list.get('title')} to={`/timelines/list/${list.get('id')}`} />);
height += 48
})
}
if (favourite_domains && !favourite_domains.isEmpty()) {
navItems.push(<ColumnSubheading key='header-sfavourite_domains' text={intl.formatMessage(messages.favourite_domains_subheading)} />);
height += 34;
favourite_domains.map(favourite_domain => {
navItems.push(<ColumnLink key={`favourite_domain:${favourite_domain.get('id')}`} icon='users' text={favourite_domain.get('name')} to={`/timelines/public/domain/${favourite_domain.get('name')}`} />);
height += 48
})
}
if (favourite_tags && !favourite_tags.isEmpty()) {
navItems.push(<ColumnSubheading key='header-favourite_tags' text={intl.formatMessage(messages.favourite_tags_subheading)} />);
height += 34;
favourite_tags.map(favourite_tag => {
navItems.push(<ColumnLink key={`favourite_tag:${favourite_tag.get('id')}`} icon='hashtag' text={favourite_tag.get('name')} to={`/timelines/tag/${favourite_tag.get('name')}`} />);
height += 48
})
}
if (myAccount.get('locked') || unreadFollowRequests > 0) {
navItems.push(<ColumnLink key='follow_requests' icon='user-plus' text={intl.formatMessage(messages.follow_requests)} badge={badgeDisplay(unreadFollowRequests, 40)} to='/follow_requests' />);
height += 48;

View file

@ -8,7 +8,7 @@ import { createSelector } from 'reselect';
import { NavLink, withRouter } from 'react-router-dom';
import Icon from 'mastodon/components/icon';
const getOrderedDomains = createSelector([state => state.get('favourite_domains')], favourite_domains => {
export const getOrderedDomains = createSelector([state => state.get('favourite_domains')], favourite_domains => {
if (!favourite_domains) {
return favourite_domains;
}

View file

@ -7,8 +7,8 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { NavLink, withRouter } from 'react-router-dom';
import Icon from 'mastodon/components/icon';
const getOrderedTags = createSelector([state => state.get('favourite_tags')], favourite_tags => {
export const getOrderedTags = createSelector([state => state.get('favourite_tags')], favourite_tags => {
if (!favourite_tags) {
return favourite_tags;
}

View file

@ -8,12 +8,12 @@ import { createSelector } from 'reselect';
import { NavLink, withRouter } from 'react-router-dom';
import Icon from 'mastodon/components/icon';
const getOrderedLists = createSelector([state => state.get('lists')], lists => {
export const getOrderedLists = createSelector([state => state.get('lists')], lists => {
if (!lists) {
return lists;
}
return lists.toList().filter(item => !!item).sort((a, b) => a.get('title').localeCompare(b.get('title'))).take(4);
return lists.toList().filter(item => !!item).sort((a, b) => a.get('title').localeCompare(b.get('title'))).take(10);
});
const mapStateToProps = state => ({

View file

@ -107,6 +107,9 @@
"column_header.pin": "Pin",
"column_header.show_settings": "Show settings",
"column_header.unpin": "Unpin",
"column_subheading.favourite_domains": "Favourite domains",
"column_subheading.favourite_tags": "Favourite tags",
"column_subheading.lists": "Lists",
"column_subheading.settings": "Settings",
"community.column_settings.local_only": "Local only",
"community.column_settings.media_only": "Media Only",

View file

@ -107,6 +107,9 @@
"column_header.pin": "ピン留めする",
"column_header.show_settings": "設定を表示",
"column_header.unpin": "ピン留めを外す",
"column_subheading.favourite_domains": "お気に入りドメイン",
"column_subheading.favourite_tags": "お気に入りハッシュタグ",
"column_subheading.lists": "リスト",
"column_subheading.settings": "設定",
"community.column_settings.local_only": "ローカルのみ表示",
"community.column_settings.media_only": "メディアのみ表示",