Skip to content

Commit

Permalink
docs: keep documentation for channelsQueryState & ChatContextValue
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela committed Nov 23, 2023
1 parent 420f58f commit d71691e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
20 changes: 20 additions & 0 deletions docusaurus/docs/React/components/contexts/chat-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ The currently active channel, which populates the [`Channel`](../core-components
| ------- |
| Channel |

### channelsQueryState

Exposes API that:

- indicates, whether and what channels query has been triggered within [`ChannelList` component](../core-components/channel-list.mdx) by its channels pagination controller - `queryInProgress` of type `ChannelQueryState`
- allows to set the `queryInProgress` state with `setQueryInProgress` state setter
- keeps track of error response from the channels query - `error`
- allows to set the `error` state with `setError`

The `queryInProgress` values are:

- `uninitialized` - the initial state before the first channels query is triggered
- `reload` - the initial channels query (loading the first page) is in progress
- `load-more` - loading the next page of channels
- `null` - at least one channels page has been loaded and there is no query in progress at the moment

| Type |
|----------------------|
| `ChannelsQueryState` |

### closeMobileNav

The function to close mobile navigation.
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chat/hooks/useChannelsQueryState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Dispatch, SetStateAction, useState } from 'react';
import type { APIErrorResponse, ErrorFromResponse } from 'stream-chat';

type ChannelQueryState =
| 'uninitialized' // the initial state before the first channels query is trigerred
| 'uninitialized' // the initial state before the first channels query is triggered
| 'reload' // the initial channels query (loading the first page) is in progress
| 'load-more' // loading the next page of channels
| null; // at least one channels page has been loaded and there is no query in progress at the moment
Expand Down
18 changes: 18 additions & 0 deletions src/context/ChatContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,38 @@ export type ThemeVersion = '1' | '2';
export type ChatContextValue<
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
> = {
/**
* Indicates, whether a channels query has been triggered within ChannelList by its channels pagination controller.
*/
channelsQueryState: ChannelsQueryState;
closeMobileNav: () => void;
getAppSettings: () => Promise<AppSettingsAPIResponse<StreamChatGenerics>> | null;
latestMessageDatesByChannels: Record<ChannelCID, Date>;
mutes: Array<Mute<StreamChatGenerics>>;
openMobileNav: () => void;
/**
* Sets active channel to be rendered within Channel component.
* @param newChannel
* @param watchers
* @param event
*/
setActiveChannel: (
newChannel?: Channel<StreamChatGenerics>,
watchers?: { limit?: number; offset?: number },
event?: React.BaseSyntheticEvent,
) => void;
/**
* Allows to opt out of the use of legacy CSS (version "1") and opt into the use of the latest SDK's CSS (version "2").
*/
themeVersion: ThemeVersion;
useImageFlagEmojisOnWindows: boolean;
/**
* Active channel used to render the contents of the Channel component.
*/
channel?: Channel<StreamChatGenerics>;
/**
* Object through which custom classes can be set for main container components of the SDK.
*/
customClasses?: CustomClasses;
navOpen?: boolean;
} & Required<Pick<ChatProps<StreamChatGenerics>, 'theme' | 'client'>>;
Expand Down

0 comments on commit d71691e

Please sign in to comment.