Skip to content

Commit 3fc3230

Browse files
ClearlyClairehiyuki2578
authored andcommitted
Add message telling FTS is disabled when no toot can be found because 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
1 parent 282e8b3 commit 3fc3230

5 files changed

Lines changed: 24 additions & 4 deletions

File tree

app/javascript/mastodon/actions/search.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function submitSearch() {
4848
dispatch(importFetchedStatuses(response.data.statuses));
4949
}
5050

51-
dispatch(fetchSearchSuccess(response.data));
51+
dispatch(fetchSearchSuccess(response.data, value));
5252
dispatch(fetchRelationships(response.data.accounts.map(item => item.id)));
5353
}).catch(error => {
5454
dispatch(fetchSearchFail(error));
@@ -62,10 +62,11 @@ export function fetchSearchRequest() {
6262
};
6363
};
6464

65-
export function fetchSearchSuccess(results) {
65+
export function fetchSearchSuccess(results, searchTerm) {
6666
return {
6767
type: SEARCH_FETCH_SUCCESS,
6868
results,
69+
searchTerm,
6970
};
7071
};
7172

app/javascript/mastodon/features/compose/components/search_results.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import StatusContainer from '../../../containers/status_container';
77
import ImmutablePureComponent from 'react-immutable-pure-component';
88
import Hashtag from '../../../components/hashtag';
99
import Icon from 'mastodon/components/icon';
10+
import { searchEnabled } from '../../../initial_state';
1011

1112
const messages = defineMessages({
1213
dismissSuggestion: { id: 'suggestions.dismiss', defaultMessage: 'Dismiss suggestion' },
@@ -20,6 +21,7 @@ class SearchResults extends ImmutablePureComponent {
2021
suggestions: ImmutablePropTypes.list.isRequired,
2122
fetchSuggestions: PropTypes.func.isRequired,
2223
dismissSuggestion: PropTypes.func.isRequired,
24+
searchTerm: PropTypes.string,
2325
intl: PropTypes.object.isRequired,
2426
};
2527

@@ -28,7 +30,7 @@ class SearchResults extends ImmutablePureComponent {
2830
}
2931

3032
render () {
31-
const { intl, results, suggestions, dismissSuggestion } = this.props;
33+
const { intl, results, suggestions, dismissSuggestion, searchTerm } = this.props;
3234

3335
if (results.isEmpty() && !suggestions.isEmpty()) {
3436
return (
@@ -76,6 +78,16 @@ class SearchResults extends ImmutablePureComponent {
7678
{results.get('statuses').map(statusId => <StatusContainer key={statusId} id={statusId} />)}
7779
</div>
7880
);
81+
} else if(results.get('statuses') && results.get('statuses').size === 0 && !searchEnabled && !(searchTerm.startsWith('@') || searchTerm.startsWith('#') || searchTerm.includes(' '))) {
82+
statuses = (
83+
<div className='search-results__section'>
84+
<h5><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Toots' /></h5>
85+
86+
<div className='search-results__info'>
87+
<FormattedMessage id='search_results.statuses_fts_disabled' defaultMessage='Searching toots by their content is not enabled on this Mastodon server.' />
88+
</div>
89+
</div>
90+
);
7991
}
8092

8193
if (results.get('hashtags') && results.get('hashtags').size > 0) {

app/javascript/mastodon/features/compose/containers/search_results_container.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { fetchSuggestions, dismissSuggestion } from '../../../actions/suggestion
55
const mapStateToProps = state => ({
66
results: state.getIn(['search', 'results']),
77
suggestions: state.getIn(['suggestions', 'items']),
8+
searchTerm: state.getIn(['search', 'value']),
89
});
910

1011
const mapDispatchToProps = dispatch => ({

app/javascript/mastodon/reducers/search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const initialState = ImmutableMap({
1616
submitted: false,
1717
hidden: false,
1818
results: ImmutableMap(),
19+
searchTerm: '',
1920
});
2021

2122
export default function search(state = initialState, action) {
@@ -40,7 +41,7 @@ export default function search(state = initialState, action) {
4041
accounts: ImmutableList(action.results.accounts.map(item => item.id)),
4142
statuses: ImmutableList(action.results.statuses.map(item => item.id)),
4243
hashtags: fromJS(action.results.hashtags),
43-
})).set('submitted', true);
44+
})).set('submitted', true).set('searchTerm', action.searchTerm);
4445
default:
4546
return state;
4647
}

app/javascript/styles/mastodon/components.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3996,6 +3996,11 @@ a.status-card.compact:hover {
39963996
}
39973997
}
39983998

3999+
.search-results__info {
4000+
padding: 10px;
4001+
color: $secondary-text-color;
4002+
}
4003+
39994004
.modal-root {
40004005
position: relative;
40014006
transition: opacity 0.3s linear;

0 commit comments

Comments
 (0)