top page selects channel tab if channel is winning

This commit is contained in:
zeppi 2020-12-07 21:53:06 -05:00 committed by Sean Yesmunt
parent 495cf89a38
commit f8d09994f6
3 changed files with 13 additions and 3 deletions

View file

@ -1504,5 +1504,8 @@
"Now following %channel%!": "Now following %channel%!",
"Turn Back On": "Turn Back On",
"Turn Off": "Turn Off",
"Search Results": "Search Results",
"View All Results": "View All Results",
"Most Supported": "Most Supported",
"--end--": "--end--"
}

View file

@ -14,21 +14,28 @@ type Props = {
winningUri: ?Claim,
doResolveUris: (Array<string>) => void,
hideLink?: boolean,
setChannelActive: boolean => void,
};
export default function SearchTopClaim(props: Props) {
const { doResolveUris, query = '', winningUri, hideLink = false } = props;
const { doResolveUris, query = '', winningUri, hideLink = false, setChannelActive } = props;
const uriFromQuery = `lbry://${query}`;
let channelUriFromQuery;
let winningUriIsChannel;
try {
const { isChannel } = parseURI(uriFromQuery);
const { isChannel: winnerIsChannel } = parseURI(winningUri);
winningUriIsChannel = winnerIsChannel;
if (!isChannel) {
channelUriFromQuery = `lbry://@${query}`;
}
} catch (e) {}
React.useEffect(() => {
setChannelActive && winningUriIsChannel && setChannelActive(true);
}, [setChannelActive, winningUriIsChannel]);
React.useEffect(() => {
let urisToResolve = [];
if (uriFromQuery) {

View file

@ -18,7 +18,7 @@ function TopPage(props: Props) {
return (
<Page>
<SearchTopClaim query={name} hideLink />
<SearchTopClaim query={name} hideLink setChannelActive={setChannelActive} />
<ClaimListDiscover
name={channelActive ? `@${name}` : name}
defaultFreshness={FRESH_ALL}