import React, { PropsWithChildren, useContext } from 'react'; import { Conversation, Group, GroupMember, Profile, } from '@tencentcloud/chat'; export interface OwnerLabelListItem { key?: string, value?: string, } export interface TUILiveActivePorps { type?: 'follow' | 'subscribe' | 'like' | 'unlike', value?: boolean, isShow?: boolean, num?: number, } export interface TUILiveCallbackParams { type?: 'follow' | 'subscribe' | 'like' | 'unlike', value?: boolean, } export interface TUILiveMemberListItemParams { title?: React.ReactElement | string, name?: string, filter?: (list: Array, ownerProfile: GroupMember) => Array, show?: boolean, } export interface TUILiveTagParam { type?: 'header' | 'footer', value?: string, ele?: React.MouseEvent } export interface IGroupCounters { [key: string] : number, } export interface GroupCounterUpdatedOption { key: string, value: number, } export interface TUILiveContextValue { url?: string, conversation?: Conversation | undefined, group?: Group | undefined, ownerProfile?: GroupMember | undefined, myProfile?: Profile | undefined, activePlugins?: Array, menuIcon?: React.ReactElement, memberGroupList?: Array, memberList?: Array, onTagClick?: (data?:TUILiveTagParam)=> void, memberCount?: number, ownerLabelList?: Array, groupCounters?: IGroupCounters | null, increaseGroupCounter?: (data: GroupCounterUpdatedOption) => Promise, decreaseGroupCounter?: (data: GroupCounterUpdatedOption) => Promise, callback?: (data?:any) => void, } export const TUILiveContext = React.createContext(undefined); export function TUILiveContextProvider({ children, value }:PropsWithChildren<{ value: TUILiveContextValue }>):React.ReactElement { return ( {children} ); } export const useTUILiveContext = (componentName?:string):TUILiveContextValue => { const contextValue = useContext(TUILiveContext); if (!contextValue && componentName) { return {} as TUILiveContextValue; } return (contextValue as unknown) as TUILiveContextValue; };