Collections: Handle URLs in search (#39182)

This commit is contained in:
Echo 2026-05-27 15:13:38 +02:00 committed by GitHub
parent 888011de69
commit d229157f19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import type { ApiAccountJSON } from './accounts'; import type { ApiAccountJSON } from './accounts';
import type { ApiCollectionJSON } from './collections';
import type { ApiStatusJSON } from './statuses'; import type { ApiStatusJSON } from './statuses';
import type { ApiHashtagJSON } from './tags'; import type { ApiHashtagJSON } from './tags';
@ -8,4 +9,5 @@ export interface ApiSearchResultsJSON {
accounts: ApiAccountJSON[]; accounts: ApiAccountJSON[];
statuses: ApiStatusJSON[]; statuses: ApiStatusJSON[];
hashtags: ApiHashtagJSON[]; hashtags: ApiHashtagJSON[];
collections: ApiCollectionJSON[];
} }

View File

@ -19,6 +19,7 @@ import { useHistory } from 'react-router-dom';
import { isFulfilled } from '@reduxjs/toolkit'; import { isFulfilled } from '@reduxjs/toolkit';
import { getCollectionPath } from '@/mastodon/features/collections/utils';
import CancelIcon from '@/material-icons/400-24px/cancel-fill.svg?react'; import CancelIcon from '@/material-icons/400-24px/cancel-fill.svg?react';
import CloseIcon from '@/material-icons/400-24px/close.svg?react'; import CloseIcon from '@/material-icons/400-24px/close.svg?react';
import SearchIcon from '@/material-icons/400-24px/search.svg?react'; import SearchIcon from '@/material-icons/400-24px/search.svg?react';
@ -337,6 +338,10 @@ export const Search: React.FC<{
history.push( history.push(
`/@${result.payload.statuses[0].account.acct}/${result.payload.statuses[0].id}`, `/@${result.payload.statuses[0].account.acct}/${result.payload.statuses[0].id}`,
); );
} else if (result.payload.collections[0]) {
history.push(
getCollectionPath(result.payload.collections[0].id),
);
} }
} }