Add chatsSearch feature
This commit is contained in:
parent
10b9a4eb4e
commit
7cf1943364
2 changed files with 17 additions and 8 deletions
|
@ -3,7 +3,7 @@ import React, { useState } from 'react';
|
|||
|
||||
import { Stack } from 'soapbox/components/ui';
|
||||
import { useChatContext } from 'soapbox/contexts/chat-context';
|
||||
import { useDebounce } from 'soapbox/hooks';
|
||||
import { useDebounce, useFeatures } from 'soapbox/hooks';
|
||||
import { IChat, useChats } from 'soapbox/queries/chats';
|
||||
|
||||
import ChatList from '../chat-list';
|
||||
|
@ -17,6 +17,7 @@ import { Pane } from '../ui';
|
|||
import Blankslate from './blankslate';
|
||||
|
||||
const ChatPane = () => {
|
||||
const features = useFeatures();
|
||||
const debounce = useDebounce;
|
||||
|
||||
const [value, setValue] = useState<string>();
|
||||
|
@ -44,13 +45,15 @@ const ChatPane = () => {
|
|||
if (hasSearchValue || Number(chats?.length) > 0) {
|
||||
return (
|
||||
<Stack space={4} className='flex-grow h-full'>
|
||||
<div className='px-4'>
|
||||
<ChatSearchInput
|
||||
value={value || ''}
|
||||
onChange={(event) => setValue(event.target.value)}
|
||||
onClear={clearValue}
|
||||
/>
|
||||
</div>
|
||||
{features.chatsSearch && (
|
||||
<div className='px-4'>
|
||||
<ChatSearchInput
|
||||
value={value || ''}
|
||||
onChange={(event) => setValue(event.target.value)}
|
||||
onClear={clearValue}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{Number(chats?.length) > 0 ? (
|
||||
<ChatList
|
||||
|
|
|
@ -204,6 +204,12 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
*/
|
||||
chats: v.software === TRUTHSOCIAL || (v.software === PLEROMA && gte(v.version, '2.1.0')),
|
||||
|
||||
/**
|
||||
* Ability to search among chats.
|
||||
* @see GET /api/v1/pleroma/chats
|
||||
*/
|
||||
chatsSearch: v.software === TRUTHSOCIAL,
|
||||
|
||||
/**
|
||||
* Paginated chats API.
|
||||
* @see GET /api/v2/chats
|
||||
|
|
Loading…
Reference in a new issue