Skip to content

Commit

Permalink
Merge pull request #179 from ulu-telegram/master
Browse files Browse the repository at this point in the history
deploy
  • Loading branch information
ulugmer authored Dec 4, 2023
2 parents 7b5e4a4 + a0527d7 commit 6523ed4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/components/left/search/CommanMenuChatSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import renderText from '../../common/helpers/renderText';
import { useJune } from '../../../hooks/useJune';
import useLang from '../../../hooks/useLang';

import CommandMenuListItem from './CommanMenuListItem';

import '../../main/CommandMenu.scss';

const CommanMenuChatSearch: React.FC<{
Expand Down Expand Up @@ -133,6 +135,10 @@ const CommanMenuChatSearch: React.FC<{
// Сортировка оставшихся чатов
const sortedChatIds = sortChatIds([...chatIds, ...userIds], chatsById);

if (searchQuery.length < 2) {
return [];
}

// Объединение приоритетных и отсортированных остальных чатов
return unique([...priorityIds, ...sortedChatIds]);
}, [searchQuery, chatsById, usersById, pinnedIds, recentlyFoundChatIds, topUserIds, currentUserId, lang]);
Expand All @@ -145,19 +151,12 @@ const CommanMenuChatSearch: React.FC<{
return (
<>
<Command.Group heading={`Search for "${searchQuery}"`}>
{ids.slice(0, 500).map((id) => {
{ids.map((id) => {
const isUser = usersById.hasOwnProperty(id);
const { content, value } = renderName(id, isUser);
// eslint-disable-next-line no-null/no-null
if (!content) return null;
if (!content) return undefined;
return (
<Command.Item
key={id}
value={value}
onSelect={handeSelect(id)}
>
{content}
</Command.Item>
<CommandMenuListItem key={id} value={value} onSelect={handeSelect(id)} content={content} />
);
})}
</Command.Group>
Expand Down
18 changes: 18 additions & 0 deletions src/components/left/search/CommanMenuListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { Command } from 'cmdk';

interface CommandMenuListItemProps {
onSelect: () => void;
content: React.ReactNode;
value: string;
}

const CommandMenuListItem: React.FC<CommandMenuListItemProps> = React.memo(({ onSelect, content, value }) => {
return (
<Command.Item value={value} onSelect={onSelect}>
{content}
</Command.Item>
);
});

export default CommandMenuListItem;

0 comments on commit 6523ed4

Please sign in to comment.