Add chatsSearch feature

This commit is contained in:
Alex Gleason 2022-09-22 16:52:31 -05:00
parent 10b9a4eb4e
commit 7cf1943364
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 17 additions and 8 deletions

View file

@ -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

View file

@ -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