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 { Stack } from 'soapbox/components/ui';
|
||||||
import { useChatContext } from 'soapbox/contexts/chat-context';
|
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 { IChat, useChats } from 'soapbox/queries/chats';
|
||||||
|
|
||||||
import ChatList from '../chat-list';
|
import ChatList from '../chat-list';
|
||||||
|
@ -17,6 +17,7 @@ import { Pane } from '../ui';
|
||||||
import Blankslate from './blankslate';
|
import Blankslate from './blankslate';
|
||||||
|
|
||||||
const ChatPane = () => {
|
const ChatPane = () => {
|
||||||
|
const features = useFeatures();
|
||||||
const debounce = useDebounce;
|
const debounce = useDebounce;
|
||||||
|
|
||||||
const [value, setValue] = useState<string>();
|
const [value, setValue] = useState<string>();
|
||||||
|
@ -44,13 +45,15 @@ const ChatPane = () => {
|
||||||
if (hasSearchValue || Number(chats?.length) > 0) {
|
if (hasSearchValue || Number(chats?.length) > 0) {
|
||||||
return (
|
return (
|
||||||
<Stack space={4} className='flex-grow h-full'>
|
<Stack space={4} className='flex-grow h-full'>
|
||||||
<div className='px-4'>
|
{features.chatsSearch && (
|
||||||
<ChatSearchInput
|
<div className='px-4'>
|
||||||
value={value || ''}
|
<ChatSearchInput
|
||||||
onChange={(event) => setValue(event.target.value)}
|
value={value || ''}
|
||||||
onClear={clearValue}
|
onChange={(event) => setValue(event.target.value)}
|
||||||
/>
|
onClear={clearValue}
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{Number(chats?.length) > 0 ? (
|
{Number(chats?.length) > 0 ? (
|
||||||
<ChatList
|
<ChatList
|
||||||
|
|
|
@ -204,6 +204,12 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
*/
|
*/
|
||||||
chats: v.software === TRUTHSOCIAL || (v.software === PLEROMA && gte(v.version, '2.1.0')),
|
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.
|
* Paginated chats API.
|
||||||
* @see GET /api/v2/chats
|
* @see GET /api/v2/chats
|
||||||
|
|
Loading…
Reference in a new issue