Skip to content

Commit

Permalink
Add message telling FTS is disabled when no toot can be found because…
Browse files Browse the repository at this point in the history
… of this (mastodon#11112)

* Add message telling FTS is disabled when no toot can be found because of this

Fixes mastodon#11082

* Remove info icon and reword message
  • Loading branch information
ClearlyClaire authored and hiyuki2578 committed Oct 2, 2019
1 parent 282e8b3 commit 3fc3230
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/javascript/mastodon/actions/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function submitSearch() {
dispatch(importFetchedStatuses(response.data.statuses));
}

dispatch(fetchSearchSuccess(response.data));
dispatch(fetchSearchSuccess(response.data, value));
dispatch(fetchRelationships(response.data.accounts.map(item => item.id)));
}).catch(error => {
dispatch(fetchSearchFail(error));
Expand All @@ -62,10 +62,11 @@ export function fetchSearchRequest() {
};
};

export function fetchSearchSuccess(results) {
export function fetchSearchSuccess(results, searchTerm) {
return {
type: SEARCH_FETCH_SUCCESS,
results,
searchTerm,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import StatusContainer from '../../../containers/status_container';
import ImmutablePureComponent from 'react-immutable-pure-component';
import Hashtag from '../../../components/hashtag';
import Icon from 'mastodon/components/icon';
import { searchEnabled } from '../../../initial_state';

const messages = defineMessages({
dismissSuggestion: { id: 'suggestions.dismiss', defaultMessage: 'Dismiss suggestion' },
Expand All @@ -20,6 +21,7 @@ class SearchResults extends ImmutablePureComponent {
suggestions: ImmutablePropTypes.list.isRequired,
fetchSuggestions: PropTypes.func.isRequired,
dismissSuggestion: PropTypes.func.isRequired,
searchTerm: PropTypes.string,
intl: PropTypes.object.isRequired,
};

Expand All @@ -28,7 +30,7 @@ class SearchResults extends ImmutablePureComponent {
}

render () {
const { intl, results, suggestions, dismissSuggestion } = this.props;
const { intl, results, suggestions, dismissSuggestion, searchTerm } = this.props;

if (results.isEmpty() && !suggestions.isEmpty()) {
return (
Expand Down Expand Up @@ -76,6 +78,16 @@ class SearchResults extends ImmutablePureComponent {
{results.get('statuses').map(statusId => <StatusContainer key={statusId} id={statusId} />)}
</div>
);
} else if(results.get('statuses') && results.get('statuses').size === 0 && !searchEnabled && !(searchTerm.startsWith('@') || searchTerm.startsWith('#') || searchTerm.includes(' '))) {
statuses = (
<div className='search-results__section'>
<h5><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Toots' /></h5>

<div className='search-results__info'>
<FormattedMessage id='search_results.statuses_fts_disabled' defaultMessage='Searching toots by their content is not enabled on this Mastodon server.' />
</div>
</div>
);
}

if (results.get('hashtags') && results.get('hashtags').size > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fetchSuggestions, dismissSuggestion } from '../../../actions/suggestion
const mapStateToProps = state => ({
results: state.getIn(['search', 'results']),
suggestions: state.getIn(['suggestions', 'items']),
searchTerm: state.getIn(['search', 'value']),
});

const mapDispatchToProps = dispatch => ({
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/mastodon/reducers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const initialState = ImmutableMap({
submitted: false,
hidden: false,
results: ImmutableMap(),
searchTerm: '',
});

export default function search(state = initialState, action) {
Expand All @@ -40,7 +41,7 @@ export default function search(state = initialState, action) {
accounts: ImmutableList(action.results.accounts.map(item => item.id)),
statuses: ImmutableList(action.results.statuses.map(item => item.id)),
hashtags: fromJS(action.results.hashtags),
})).set('submitted', true);
})).set('submitted', true).set('searchTerm', action.searchTerm);
default:
return state;
}
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3996,6 +3996,11 @@ a.status-card.compact:hover {
}
}

.search-results__info {
padding: 10px;
color: $secondary-text-color;
}

.modal-root {
position: relative;
transition: opacity 0.3s linear;
Expand Down

0 comments on commit 3fc3230

Please sign in to comment.