Fixed error message to include numbers #2336

Merged
eggplantbren merged 2 commits from master into master 2019-03-15 01:07:41 +01:00

View file

@ -81,7 +81,7 @@ class WunderBar extends React.PureComponent<Props> {
} }
handleSubmit(value: string, suggestion?: { value: string, type: string }) { handleSubmit(value: string, suggestion?: { value: string, type: string }) {
const { onSubmit, onSearch } = this.props; const { onSubmit, onSearch, doShowSnackBar } = this.props;
const query = value.trim(); const query = value.trim();
const getParams = () => { const getParams = () => {
const parts = query.split('?'); const parts = query.split('?');
@ -94,6 +94,12 @@ class WunderBar extends React.PureComponent<Props> {
return extraParams; return extraParams;
}; };
const showSnackError = () => {
doShowSnackBar({
message: __('Invalid LBRY URL entered. Only A-Z, a-z, 0-9, and "-" allowed.'),
});
};
// User selected a suggestion // User selected a suggestion
if (suggestion) { if (suggestion) {
if (suggestion.type === 'search') { if (suggestion.type === 'search') {
@ -103,9 +109,7 @@ class WunderBar extends React.PureComponent<Props> {
const uri = normalizeURI(query); const uri = normalizeURI(query);
onSubmit(uri, params); onSubmit(uri, params);
} else { } else {
this.props.doShowSnackBar({ showSnackError();
message: __('Invalid LBRY URL entered. Only A-Z, a-z, and - allowed.'),
});
} }
return; return;
@ -119,9 +123,7 @@ class WunderBar extends React.PureComponent<Props> {
const params = getParams(); const params = getParams();
onSubmit(uri, params); onSubmit(uri, params);
} else { } else {
this.props.doShowSnackBar({ showSnackError();
message: __('Invalid LBRY URL entered. Only A-Z, a-z, and - allowed.'),
});
} }
} catch (e) { } catch (e) {
onSearch(query); onSearch(query);