From 6f67af5ec3f6d184a0ef5366fc6dc010653c6ffc Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Thu, 18 Feb 2021 16:55:29 +0800 Subject: [PATCH] Make educated guess if 'no result' is due to language filter, and warn user. --- static/app-strings.json | 2 +- ui/component/claimList/index.js | 13 +++++++------ ui/component/claimList/view.jsx | 21 +++++++++++---------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index 7c01c3754..6bd4e3beb 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -18,6 +18,7 @@ "Settings": "Settings", "Help": "Help", "No results": "No results", + "No results. Contents may be hidden by the Language filter.": "No results. Contents may be hidden by the Language filter.", "Home": "Home", "Library": "Library", "Purchased": "Purchased", @@ -1531,7 +1532,6 @@ "Explore": "Explore", "There is a bug... somewhere": "There is a bug... somewhere", "Try refreshing to fix the issue. If that doesn't work, email help@lbry.com for support.": "Try refreshing to fix the issue. If that doesn't work, email help@lbry.com for support.", - "No Results": "No Results", "Content preview": "Content preview", "Repost url": "Repost url", "Close sidebar - hide channels you are following": "Close sidebar - hide channels you are following", diff --git a/ui/component/claimList/index.js b/ui/component/claimList/index.js index 55ef525f8..dd35bb3ca 100644 --- a/ui/component/claimList/index.js +++ b/ui/component/claimList/index.js @@ -1,11 +1,12 @@ import { connect } from 'react-redux'; import ClaimList from './view'; +import { SETTINGS } from 'lbry-redux'; +import { makeSelectClientSetting } from 'redux/selectors/settings'; -const select = state => ({}); +const select = (state) => ({ + searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state), +}); -const perform = dispatch => ({}); +const perform = (dispatch) => ({}); -export default connect( - select, - perform -)(ClaimList); +export default connect(select, perform)(ClaimList); diff --git a/ui/component/claimList/view.jsx b/ui/component/claimList/view.jsx index 685e33fa7..e8ef2053b 100644 --- a/ui/component/claimList/view.jsx +++ b/ui/component/claimList/view.jsx @@ -22,7 +22,7 @@ type Props = { type: string, empty?: string, defaultSort?: boolean, - onScrollBottom?: any => void, + onScrollBottom?: (any) => void, page?: number, pageSize?: number, id?: string, @@ -36,7 +36,8 @@ type Props = { injectedItem: ?Node, timedOutMessage?: Node, tileLayout?: boolean, - renderActions?: Claim => ?Node, + renderActions?: (Claim) => ?Node, + searchInLanguage: boolean, }; export default function ClaimList(props: Props) { @@ -61,19 +62,23 @@ export default function ClaimList(props: Props) { timedOutMessage, tileLayout = false, renderActions, + searchInLanguage, } = props; const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW); const timedOut = uris === null; const urisLength = (uris && uris.length) || 0; const sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? uris : uris.slice().reverse())) || []; + const noResultMsg = searchInLanguage + ? __('No results. Contents may be hidden by the Language filter.') + : __('No results'); function handleSortChange() { setCurrentSort(currentSort === SORT_NEW ? SORT_OLD : SORT_NEW); } useEffect(() => { - const handleScroll = debounce(e => { + const handleScroll = debounce((e) => { if (page && pageSize && onScrollBottom) { const mainEl = document.querySelector(`.${MAIN_CLASS}`); @@ -95,10 +100,8 @@ export default function ClaimList(props: Props) { return tileLayout && !header ? (
- {urisLength > 0 && uris.map(uri => )} - {!timedOut && urisLength === 0 && !loading && ( -
{empty || __('No results')}
- )} + {urisLength > 0 && uris.map((uri) => )} + {!timedOut && urisLength === 0 && !loading &&
{empty || noResultMsg}
} {timedOut && timedOutMessage &&
{timedOutMessage}
}
) : ( @@ -168,9 +171,7 @@ export default function ClaimList(props: Props) { )} - {!timedOut && urisLength === 0 && !loading && ( -
{empty || __('No results')}
- )} + {!timedOut && urisLength === 0 && !loading &&
{empty || noResultMsg}
} {!loading && timedOut && timedOutMessage &&
{timedOutMessage}
} );