bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/components-data/plugin-context/context.tsx
Guilherme Pereira Leme b23bea041c
feat(plugin): Implemented first dom element manipulation - chat message (#19420)
* [plugin-sdk-refactor-2] - refactored some filenames and enums.

* [plugin-sdk-issue-28] - Implemented dom element manipulation

* [plugin-sdk-issue-28] - bump plugin-sdk version
2024-01-16 14:02:12 -03:00

42 lines
1.7 KiB
TypeScript

import React, { createContext, useState } from 'react';
import { ExtensibleArea } from '/imports/ui/components/plugins-engine/extensible-areas/types';
import { ChatMessagesGraphqlVariablesAndQuery, PluginsContextType, UserListGraphqlVariables } from './types';
import { CHAT_MESSAGE_PUBLIC_SUBSCRIPTION } from '../../chat/chat-graphql/chat-message-list/page/queries';
export const PluginsContext = createContext<PluginsContextType>({} as PluginsContextType);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const PluginsContextProvider = ({ children, ...props }: any) => {
const [pluginsExtensibleAreasAggregatedState, setPluginsExtensibleAreasAggregatedState] = useState<ExtensibleArea>(
{} as ExtensibleArea,
);
const [userListGraphqlVariables, setUserListGraphqlVariables] = useState<UserListGraphqlVariables>(
{} as UserListGraphqlVariables,
);
const [domElementManipulationMessageIds, setDomElementManipulationMessageIds] = useState<string[]>([]);
const [
chatMessagesGraphqlVariablesAndQuery,
setChatMessagesGraphqlVariablesAndQuery,
] = useState<ChatMessagesGraphqlVariablesAndQuery>(
{ query: CHAT_MESSAGE_PUBLIC_SUBSCRIPTION } as ChatMessagesGraphqlVariablesAndQuery,
);
return (
<PluginsContext.Provider
value={{
...props,
setPluginsExtensibleAreasAggregatedState,
pluginsExtensibleAreasAggregatedState,
userListGraphqlVariables,
setUserListGraphqlVariables,
chatMessagesGraphqlVariablesAndQuery,
setChatMessagesGraphqlVariablesAndQuery,
domElementManipulationMessageIds,
setDomElementManipulationMessageIds,
}}
>
{children}
</PluginsContext.Provider>
);
};