lemmy-ui/src/shared/utils/app/community-search.ts
2023-07-28 16:15:42 -04:00

14 lines
431 B
TypeScript

import { fetchCommunities } from "@utils/app";
import { hostname } from "@utils/helpers";
import { CommunityTribute } from "@utils/types";
export default async function communitySearch(
text: string,
): Promise<CommunityTribute[]> {
const communitiesResponse = await fetchCommunities(text);
return communitiesResponse.map(cv => ({
key: `!${cv.community.name}@${hostname(cv.community.actor_id)}`,
view: cv,
}));
}