fix 1972
Adds a snackbar if the lbry:// URL is invalid I tried to do the doNotify similar to most of the other pages, but failed.
This commit is contained in:
parent
352363056c
commit
2707210744
1 changed files with 25 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { normalizeURI, SEARCH_TYPES } from 'lbry-redux';
|
import { normalizeURI, SEARCH_TYPES, doNotify, isURIValid } from 'lbry-redux';
|
||||||
import Icon from 'component/common/icon';
|
import Icon from 'component/common/icon';
|
||||||
import { parseQueryParams } from 'util/query_params';
|
import { parseQueryParams } from 'util/query_params';
|
||||||
import * as icons from 'constants/icons';
|
import * as icons from 'constants/icons';
|
||||||
|
@ -101,9 +101,18 @@ class WunderBar extends React.PureComponent<Props> {
|
||||||
if (suggestion.type === 'search') {
|
if (suggestion.type === 'search') {
|
||||||
onSearch(query, resultCount);
|
onSearch(query, resultCount);
|
||||||
} else {
|
} else {
|
||||||
|
if (isURIValid(query)) {
|
||||||
const params = getParams();
|
const params = getParams();
|
||||||
const uri = normalizeURI(query);
|
const uri = normalizeURI(query);
|
||||||
onSubmit(uri, params);
|
onSubmit(uri, params);
|
||||||
|
} else {
|
||||||
|
window.app.store.dispatch(
|
||||||
|
doNotify({
|
||||||
|
message: __('Invalid LBRY URL requested. Only A-Z, a-z, and - allowed.'),
|
||||||
|
displayType: ['snackbar'],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -112,9 +121,18 @@ class WunderBar extends React.PureComponent<Props> {
|
||||||
// Currently no suggestion is highlighted. The user may have started
|
// Currently no suggestion is highlighted. The user may have started
|
||||||
// typing, then lost focus and came back later on the same page
|
// typing, then lost focus and came back later on the same page
|
||||||
try {
|
try {
|
||||||
|
if (isURIValid(query)) {
|
||||||
const uri = normalizeURI(query);
|
const uri = normalizeURI(query);
|
||||||
const params = getParams();
|
const params = getParams();
|
||||||
onSubmit(uri, params);
|
onSubmit(uri, params);
|
||||||
|
} else {
|
||||||
|
window.app.store.dispatch(
|
||||||
|
doNotify({
|
||||||
|
message: __('Invalid LBRY URL entered. Only A-Z, a-z, and - allowed.'),
|
||||||
|
displayType: ['snackbar'],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
onSearch(query, resultCount);
|
onSearch(query, resultCount);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue