Merge remote-tracking branch 'parent/main' into kb_lts
This commit is contained in:
commit
7a36615f0e
5 changed files with 146 additions and 173 deletions
|
@ -6,6 +6,7 @@ import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|||
import classNames from 'classnames';
|
||||
import { Helmet } from 'react-helmet';
|
||||
|
||||
import { List as ImmutableList } from 'immutable';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
|
@ -168,7 +169,7 @@ class About extends PureComponent {
|
|||
</Section>
|
||||
|
||||
<Section title={intl.formatMessage(messages.rules)}>
|
||||
{!isLoading && (server.get('rules', []).isEmpty() ? (
|
||||
{!isLoading && (server.get('rules', ImmutableList()).isEmpty() ? (
|
||||
<p><FormattedMessage id='about.not_available' defaultMessage='This information has not been made available on this server.' /></p>
|
||||
) : (
|
||||
<ol className='rules-list'>
|
||||
|
|
|
@ -29,7 +29,6 @@ class SearchResults extends ImmutablePureComponent {
|
|||
results: ImmutablePropTypes.map.isRequired,
|
||||
expandSearch: PropTypes.func.isRequired,
|
||||
searchTerm: PropTypes.string,
|
||||
noMoreResults: ImmutablePropTypes.map,
|
||||
};
|
||||
|
||||
handleLoadMoreAccounts = () => this.props.expandSearch('accounts');
|
||||
|
@ -38,8 +37,6 @@ class SearchResults extends ImmutablePureComponent {
|
|||
|
||||
handleLoadMoreHashtags = () => this.props.expandSearch('hashtags');
|
||||
|
||||
showMoreResults = (searchType) => this.props.noMoreResults ? !this.props.noMoreResults.get(searchType) : true;
|
||||
|
||||
render () {
|
||||
const { results } = this.props;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
SEARCH_SHOW,
|
||||
SEARCH_EXPAND_REQUEST,
|
||||
SEARCH_EXPAND_SUCCESS,
|
||||
SEARCH_EXPAND_FAIL,
|
||||
SEARCH_HISTORY_UPDATE,
|
||||
} from '../actions/search';
|
||||
|
||||
|
@ -22,7 +23,6 @@ const initialState = ImmutableMap({
|
|||
submitted: false,
|
||||
hidden: false,
|
||||
results: ImmutableMap(),
|
||||
noMoreResults: ImmutableMap(),
|
||||
isLoading: false,
|
||||
searchTerm: '',
|
||||
type: null,
|
||||
|
@ -37,7 +37,6 @@ export default function search(state = initialState, action) {
|
|||
return state.withMutations(map => {
|
||||
map.set('value', '');
|
||||
map.set('results', ImmutableMap());
|
||||
map.set('noMoreResults', ImmutableMap());
|
||||
map.set('submitted', false);
|
||||
map.set('hidden', false);
|
||||
map.set('searchTerm', '');
|
||||
|
@ -56,6 +55,7 @@ export default function search(state = initialState, action) {
|
|||
map.set('type', action.searchType);
|
||||
});
|
||||
case SEARCH_FETCH_FAIL:
|
||||
case SEARCH_EXPAND_FAIL:
|
||||
return state.set('isLoading', false);
|
||||
case SEARCH_FETCH_SUCCESS:
|
||||
return state.withMutations(map => {
|
||||
|
@ -64,21 +64,16 @@ export default function search(state = initialState, action) {
|
|||
statuses: ImmutableOrderedSet(action.results.statuses.map(item => item.id)),
|
||||
hashtags: ImmutableOrderedSet(fromJS(action.results.hashtags)),
|
||||
}));
|
||||
map.set('noMoreResults', ImmutableMap({
|
||||
accounts: action.results.accounts.length <= 0,
|
||||
statuses: action.results.statuses.length <= 0,
|
||||
hashtags: false,
|
||||
}));
|
||||
|
||||
map.set('searchTerm', action.searchTerm);
|
||||
map.set('type', action.searchType);
|
||||
map.set('isLoading', false);
|
||||
});
|
||||
case SEARCH_EXPAND_REQUEST:
|
||||
return state.set('type', action.searchType);
|
||||
return state.set('type', action.searchType).set('isLoading', true);
|
||||
case SEARCH_EXPAND_SUCCESS:
|
||||
const results = action.searchType === 'hashtags' ? ImmutableOrderedSet(fromJS(action.results.hashtags)) : action.results[action.searchType].map(item => item.id);
|
||||
return state.updateIn(['results', action.searchType], list => list.union(results)).setIn(['noMoreResults', action.searchType], results.size <= 0);
|
||||
return state.updateIn(['results', action.searchType], list => list.union(results)).set('isLoading', false);
|
||||
case SEARCH_HISTORY_UPDATE:
|
||||
return state.set('recent', ImmutableOrderedSet(fromJS(action.recent)));
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue