Fix duplicated search results

Also fix other stuff
This commit is contained in:
Lim Chee Aun 2023-06-30 09:48:52 +08:00
parent 4476e9d087
commit d035d18aa0

View file

@ -87,7 +87,7 @@ function Search(props) {
try { try {
const results = await masto.v2.search(params); const results = await masto.v2.search(params);
console.log(results); console.log(results);
if (type) { if (type && !firstLoad) {
if (type === 'statuses') { if (type === 'statuses') {
setStatusResults((prev) => [...prev, ...results.statuses]); setStatusResults((prev) => [...prev, ...results.statuses]);
} else if (type === 'accounts') { } else if (type === 'accounts') {
@ -174,7 +174,7 @@ function Search(props) {
<> <>
<ul class="timeline flat accounts-list"> <ul class="timeline flat accounts-list">
{accountResults.map((account) => ( {accountResults.map((account) => (
<li> <li key={account.id}>
<AccountBlock <AccountBlock
account={account} account={account}
instance={instance} instance={instance}
@ -193,12 +193,15 @@ function Search(props) {
</div> </div>
)} )}
</> </>
) : uiState === 'loading' ? (
<p class="ui-state">
<Loader abrupt />
</p>
) : ( ) : (
<p class="ui-state">No accounts found.</p> !type &&
(uiState === 'loading' ? (
<p class="ui-state">
<Loader abrupt />
</p>
) : (
<p class="ui-state">No accounts found.</p>
))
)} )}
</> </>
)} )}
@ -211,7 +214,7 @@ function Search(props) {
<> <>
<ul class="link-list hashtag-list"> <ul class="link-list hashtag-list">
{hashtagResults.map((hashtag) => ( {hashtagResults.map((hashtag) => (
<li> <li key={hashtag.name}>
<Link <Link
to={ to={
instance instance
@ -236,12 +239,15 @@ function Search(props) {
</div> </div>
)} )}
</> </>
) : uiState === 'loading' ? (
<p class="ui-state">
<Loader abrupt />
</p>
) : ( ) : (
<p class="ui-state">No hashtags found.</p> !type &&
(uiState === 'loading' ? (
<p class="ui-state">
<Loader abrupt />
</p>
) : (
<p class="ui-state">No hashtags found.</p>
))
)} )}
</> </>
)} )}
@ -254,7 +260,7 @@ function Search(props) {
<> <>
<ul class="timeline"> <ul class="timeline">
{statusResults.map((status) => ( {statusResults.map((status) => (
<li> <li key={status.id}>
<Link <Link
class="status-link" class="status-link"
to={ to={
@ -279,12 +285,15 @@ function Search(props) {
</div> </div>
)} )}
</> </>
) : uiState === 'loading' ? (
<p class="ui-state">
<Loader abrupt />
</p>
) : ( ) : (
<p class="ui-state">No posts found.</p> !type &&
(uiState === 'loading' ? (
<p class="ui-state">
<Loader abrupt />
</p>
) : (
<p class="ui-state">No posts found.</p>
))
)} )}
</> </>
)} )}