Fix history key might be undefined in hashtag object

And some other fixes
This commit is contained in:
Lim Chee Aun 2023-12-03 13:09:05 +08:00
parent 2ad72a667d
commit 810596b7cf

View file

@ -253,21 +253,21 @@ function Search(props) {
<ul class="link-list hashtag-list"> <ul class="link-list hashtag-list">
{hashtagResults.map((hashtag) => { {hashtagResults.map((hashtag) => {
const { name, history } = hashtag; const { name, history } = hashtag;
const total = history.reduce( const total = history?.reduce?.(
(acc, cur) => acc + +cur.uses, (acc, cur) => acc + +cur.uses,
0, 0,
); );
return ( return (
<li key={hashtag.name}> <li key={`${name}-${total}`}>
<Link <Link
to={ to={
instance instance
? `/${instance}/t/${hashtag.name}` ? `/${instance}/t/${name}`
: `/t/${hashtag.name}` : `/t/${name}`
} }
> >
<Icon icon="hashtag" /> <Icon icon="hashtag" />
<span>{hashtag.name}</span> <span>{name}</span>
{!!total && ( {!!total && (
<span class="count"> <span class="count">
{shortenNumber(total)} {shortenNumber(total)}