UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

57 lines (56 loc) 3.06 kB
import type { Channel, ChannelSort, ChannelSortBase, ExtendableGenerics } from 'stream-chat'; import type { DefaultStreamChatGenerics } from '../../types/types'; import type { ChannelListProps } from './ChannelList'; export declare const MAX_QUERY_CHANNELS_LIMIT = 30; type MoveChannelUpParams<SCG extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = { channels: Array<Channel<SCG>>; cid: string; activeChannel?: Channel<SCG>; }; /** * @deprecated */ export declare const moveChannelUp: <SCG extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ activeChannel, channels, cid, }: MoveChannelUpParams<SCG>) => Channel<SCG>[]; /** * Expects channel array sorted by `{ pinned_at: -1 }`. * * TODO: add support for the `{ pinned_at: 1 }` */ export declare function findLastPinnedChannelIndex<SCG extends ExtendableGenerics>({ channels, }: { channels: Channel<SCG>[]; }): number | null; type MoveChannelUpwardsParams<SCG extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = { channels: Array<Channel<SCG>>; channelToMove: Channel<SCG>; sort: ChannelSort<SCG>; /** * If the index of the channel within `channels` list which is being moved upwards * (`channelToMove`) is known, you can supply it to skip extra calculation. */ channelToMoveIndexWithinChannels?: number; }; export declare const moveChannelUpwards: <SCG extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ channels, channelToMove, channelToMoveIndexWithinChannels, sort, }: MoveChannelUpwardsParams<SCG>) => Channel<SCG>[]; /** * Returns `true` only if object with `pinned_at` property is first within the `sort` array * or if `pinned_at` key of the `sort` object gets picked first when using `for...in` looping mechanism * and value of the `pinned_at` is either `1` or `-1`. */ export declare const shouldConsiderPinnedChannels: <SCG extends ExtendableGenerics>(sort: ChannelListProps<SCG>['sort']) => boolean; export declare const extractSortValue: <SCG extends ExtendableGenerics>({ atIndex, sort, targetKey, }: { atIndex: number; targetKey: keyof ChannelSortBase<SCG>; sort?: ChannelListProps<SCG>['sort']; }) => NonNullable<ChannelSortBase<SCG>["created_at" | "pinned_at" | "updated_at" | keyof SCG["channelType"] | "has_unread" | "last_message_at" | "last_updated" | "member_count" | "unread_count"]> | null; /** * Returns `true` only if `archived` property is of type `boolean` within `filters` object. */ export declare const shouldConsiderArchivedChannels: <SCG extends ExtendableGenerics>(filters: ChannelListProps<SCG>['filters']) => boolean; /** * Returns `true` only if `pinned_at` property is of type `string` within `membership` object. */ export declare const isChannelPinned: <SCG extends ExtendableGenerics>(channel: Channel<SCG>) => boolean; /** * Returns `true` only if `archived_at` property is of type `string` within `membership` object. */ export declare const isChannelArchived: <SCG extends ExtendableGenerics>(channel: Channel<SCG>) => boolean; export {};