diff --git a/README.md b/README.md index 223e0209..41d3ec29 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ follow these steps: ```bash cd $HOME/src/bigbluebutton-html-plugin-sdk/samples/sample-action-button-dropdown-plugin -npm install +npm ci npm run build-bundle ``` @@ -142,7 +142,7 @@ Here is as complete `manifet.json` example with all possible configurations: { "name": "allUsers", "url": "${meta_pluginSettingsUserInformation}", - "fetchMode": "onMeetingCreate", + "fetchMode": "onMeetingCreate", // Possible values: "onMeetingCreate", "onDemand" "permissions": ["moderator", "viewer"] } ] @@ -188,10 +188,11 @@ That being said, here are the extensible areas we have so far: Mind that no plugin will interfere into another's extensible area. So feel free to set whatever you need into a certain plugin with no worries. -### Getters available through the API: +### Auxiliar functions: - `getSessionToken`: returns the user session token located on the user's URL. - `getJoinUrl`: returns the join url associated with the parameters passed as an argument. Since it fetches the BigBlueButton API, this getter method is asynchronous. +- `useLocaleMessages`: returns the messages to be used in internationalization functions (recommend to use `react-intl`, as example, refer to official plugins) ### Realtime data consumption @@ -397,21 +398,32 @@ This is possible by simply configuring the dataResource name in the manifest and { "name": "allUsers", "url": "${meta_pluginSettingsUserInformation}", - "fetchMode": "onMeetingCreate", - "permissions": ["moderator", "viewer"] + "fetchMode": "onMeetingCreate", // Possible values: "onMeetingCreate", "onDemand" + "permissions": ["moderator", "viewer"] // Possible values: "moderator", "viewer", "presenter" } ] } ``` -Then when creating the meeting send the following parameters along, adjusting to your needs and resources: +Going through each parameter to better understand it's structure: + +- `name`: It is the name of the remote data source, that is the name you'll use later on in the plugin when developing it; +- `url`: The Url to which the data will be fetched (it can be hard-coded in the `manifest.json`, but we recommend passing it as a `meta_` parameter); +- `fetchMode`: It tells the plugin-server if it should fetch the data only when creating the meeting, or everytime the function is called in the plugin portion; + - If one chooses `onMeetingCreate`, the data will be fetched when the create endpoint of the meeting is called, then it's cached in the plugin-server so that everytime the plugin wants that data, the plugin-server will respond with the cached data; + - On the other hand, if `onDemand` is selected, everytime the plugin calls this method, the plugin-server will fetch the data and then proxy it to the plugin; +- `permissions`: This tells the back-end which role of the meeting can access this remote data; + +Here is the `/create` parameters you would have to pass to make this remote-data-source api work: ``` meta_pluginSettingsUserInformation=https:///api/users pluginManifests=[{"url": "http:///your-plugin/manifest.json"}] ``` -In the plugin, just use the function like: +See that we send the `meta_` parameter, for more information, refer to the [meta parameters section](#meta_-parameters) + +Lastly, in the plugin, just use the function like: ```typescript pluginApi.getRemoteData('allUsers').then((response: Response) => { @@ -427,6 +439,12 @@ pluginApi.getRemoteData('allUsers').then((response: Response) => { }); ``` +### Meta_ parameters + +This is not part of the API, but it's a way of passing information to the manifest. Any value can be passed like this, one just needs to put something like `${meta_nameOfParameter}` in a specific config of the manifest, and in the `/create` call, set this meta-parameter to whatever is preferred, like `meta_nameOfParameter="Sample message"` + +This feature is mainly used for security purposes, see [external data section](#external-data-resources). But can be used for customization reasons as well. + ### Event persistence This feature will allow the developer to save an information (which is basically an event) in the `event.xml` file of the meeting if it's being recorded. diff --git a/package-lock.json b/package-lock.json index 6d3eba6f..3e792968 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bigbluebutton-html-plugin-sdk", - "version": "0.0.70", + "version": "0.0.73", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bigbluebutton-html-plugin-sdk", - "version": "0.0.70", + "version": "0.0.73", "license": "LGPL-3.0", "dependencies": { "@apollo/client": "^3.8.7", diff --git a/package.json b/package.json index 33ed4431..e38a846c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bigbluebutton-html-plugin-sdk", - "version": "0.0.70", + "version": "0.0.73", "homepage": "https://github.com/bigbluebutton/bigbluebutton-html-plugin-sdk", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", diff --git a/samples/sample-action-button-dropdown-plugin/manifest.json b/samples/sample-action-button-dropdown-plugin/manifest.json index a04ff4f8..bbb6ec40 100644 --- a/samples/sample-action-button-dropdown-plugin/manifest.json +++ b/samples/sample-action-button-dropdown-plugin/manifest.json @@ -3,9 +3,5 @@ "name": "SampleActionButtonDropdownPlugin", "javascriptEntrypointUrl": "SampleActionButtonDropdownPlugin.js", "localesBaseUrl": "https://cdn.dominio.com/pluginabc/", - "assetPersistence": { - "enabled": true, - "maxFileSize": 10000000, - "maxUploadSizePerUser": 100000000 - } + "enabledForBreakoutRooms": true } diff --git a/samples/sample-action-button-dropdown-plugin/package-lock.json b/samples/sample-action-button-dropdown-plugin/package-lock.json index 4db35149..110ad5ee 100644 --- a/samples/sample-action-button-dropdown-plugin/package-lock.json +++ b/samples/sample-action-button-dropdown-plugin/package-lock.json @@ -14,7 +14,7 @@ "@types/react": "^18.2.13", "@types/react-dom": "^18.2.6", "babel-plugin-syntax-dynamic-import": "^6.18.0", - "bigbluebutton-html-plugin-sdk": "0.0.70", + "bigbluebutton-html-plugin-sdk": "0.0.73", "path": "^0.12.7", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -3468,9 +3468,9 @@ "dev": true }, "node_modules/bigbluebutton-html-plugin-sdk": { - "version": "0.0.70", - "resolved": "https://registry.npmjs.org/bigbluebutton-html-plugin-sdk/-/bigbluebutton-html-plugin-sdk-0.0.70.tgz", - "integrity": "sha512-TxNaRin5wQPVETB0l2vwidogWqlfYxRsdBvOsuldu8i/wREA+K+jIGfdRwRZaO2BhpIy+HlpPKwlIPYg7fOaDw==", + "version": "0.0.73", + "resolved": "https://registry.npmjs.org/bigbluebutton-html-plugin-sdk/-/bigbluebutton-html-plugin-sdk-0.0.73.tgz", + "integrity": "sha512-upf5Np45+F26qlad1ZUDJFFyAFyPHF3cU81jskEUq2VoEzUCX8zjBVvIsksut79Slz/B622UbX8blGTm+s7/lw==", "dependencies": { "@apollo/client": "^3.8.7", "@browser-bunyan/console-formatted-stream": "^1.8.0", @@ -12270,9 +12270,9 @@ "dev": true }, "bigbluebutton-html-plugin-sdk": { - "version": "0.0.70", - "resolved": "https://registry.npmjs.org/bigbluebutton-html-plugin-sdk/-/bigbluebutton-html-plugin-sdk-0.0.70.tgz", - "integrity": "sha512-TxNaRin5wQPVETB0l2vwidogWqlfYxRsdBvOsuldu8i/wREA+K+jIGfdRwRZaO2BhpIy+HlpPKwlIPYg7fOaDw==", + "version": "0.0.73", + "resolved": "https://registry.npmjs.org/bigbluebutton-html-plugin-sdk/-/bigbluebutton-html-plugin-sdk-0.0.73.tgz", + "integrity": "sha512-upf5Np45+F26qlad1ZUDJFFyAFyPHF3cU81jskEUq2VoEzUCX8zjBVvIsksut79Slz/B622UbX8blGTm+s7/lw==", "requires": { "@apollo/client": "^3.8.7", "@browser-bunyan/console-formatted-stream": "^1.8.0", diff --git a/samples/sample-action-button-dropdown-plugin/package.json b/samples/sample-action-button-dropdown-plugin/package.json index 5cd96b89..7ccc2220 100644 --- a/samples/sample-action-button-dropdown-plugin/package.json +++ b/samples/sample-action-button-dropdown-plugin/package.json @@ -10,7 +10,7 @@ "@types/react": "^18.2.13", "@types/react-dom": "^18.2.6", "babel-plugin-syntax-dynamic-import": "^6.18.0", - "bigbluebutton-html-plugin-sdk": "0.0.70", + "bigbluebutton-html-plugin-sdk": "0.0.73", "path": "^0.12.7", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx b/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx index 12146d6f..399b8034 100644 --- a/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx +++ b/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import { useState, useEffect } from 'react'; -import { AssetType } from 'bigbluebutton-html-plugin-sdk/dist/cjs/asset-persistence/enums'; import * as ReactModal from 'react-modal'; import './style.css'; @@ -45,26 +44,18 @@ function SampleActionButtonDropdownPlugin( const [isCamerasOnly, setIsCamerasOnly] = useState(false); + const [isSelfViewDisabled, setIsSelfViewDisabled] = useState(false); const { data: isMeetingBreakoutFromGraphql } = pluginApi.useCustomSubscription< IsMeetingBreakoutGraphqlResponse>(IS_MEETING_BREAKOUT); useEffect(() => { - // This line is commented once it will upload a - // PDF everytime you enter a meeting - // (if you have presenter role). - // Uncomment them to test this feature! - pluginApi.persistAsset( - 'https://pdfobject.com/pdf/sample.pdf', - AssetType.PRESENTATION, - 'my-presentation.pdf', - ); pluginApi.uiCommands.notification.send({ message: 'Notification message', icon: 'presentation', type: NotificationTypeUiCommand.INFO, options: { - // helpLabel: 'test help label', // this is not necessary - // helpLink: 'test help link', + // helpLabel: 'teste help label', // this is not necessary + // helpLink: 'teste help link', autoClose: 20000, }, content: 'Content of my notification', @@ -165,6 +156,15 @@ function SampleActionButtonDropdownPlugin( }, 5000); }, }), + new ActionButtonDropdownOption({ + label: 'Stop notifications', + icon: 'copy', + tooltip: 'this is a button injected by plugin', + allowed: true, + onClick: () => { + pluginApi.uiCommands.notification.setEnabledDisplayNotifications(false); + }, + }), new ActionButtonDropdownOption({ label: showingGenericContentInPresentationArea ? 'Return previous presentation content' : 'Set different content in presentation area', icon: 'copy', @@ -189,9 +189,27 @@ function SampleActionButtonDropdownPlugin( setIsCamerasOnly(false); }, }), + new ActionButtonDropdownOption({ + label: !(isSelfViewDisabled) ? 'Disable camera self view' : 'Enable self view', + icon: 'desktop', + tooltip: 'this is a button injected by plugin', + allowed: true, + onClick: !(isSelfViewDisabled) ? () => { + setIsSelfViewDisabled(true); + pluginApi.uiCommands.camera.setSelfViewDisableAllDevices({ + isSelfViewDisabledAllDevices: true, + }); + } : () => { + setIsSelfViewDisabled(false); + pluginApi.uiCommands.camera.setSelfViewDisableAllDevices({ + isSelfViewDisabledAllDevices: false, + }); + }, + }), ]); } - }, [currentPresentation, currentUser, showingGenericContentInPresentationArea, isCamerasOnly]); + }, [currentPresentation, currentUser, isSelfViewDisabled, + showingGenericContentInPresentationArea]); return ( { - window.dispatchEvent( - new CustomEvent< - AssetPersistenceDetails>(AssetPersistenceEvents.ASSET_PERSISTED, { - detail: { - pluginName, - assetUrl, - typeOfAsset, - assetName, - }, - }), - ); -}; diff --git a/src/asset-persistence/types.ts b/src/asset-persistence/types.ts deleted file mode 100644 index 0a90fca7..00000000 --- a/src/asset-persistence/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { AssetType } from './enums'; - -export interface AssetPersistenceDetails { - pluginName: string; - assetUrl: string; - typeOfAsset: AssetType; - assetName?: string; -} - -export type PersistAssetFunction = ( - assetUrl: string, - typeOfAsset: AssetType, - assetName?: string, -) => void; diff --git a/src/core/api/BbbPluginSdk.ts b/src/core/api/BbbPluginSdk.ts index c556344c..c6158239 100644 --- a/src/core/api/BbbPluginSdk.ts +++ b/src/core/api/BbbPluginSdk.ts @@ -48,8 +48,7 @@ import { sendGenericDataForLearningAnalyticsDashboard } from '../../learning-ana import { GenericDataForLearningAnalyticsDashboard } from '../../learning-analytics-dashboard/types'; import { getRemoteData } from '../../remote-data/utils'; import { persistEventFunctionWrapper } from '../../event-persistence/hooks'; -import { persistAssetFunctionWrapper } from '../../asset-persistence/hook'; -import { AssetType } from '../../asset-persistence/enums'; +import useLocaleMessagesAuxiliary from '../auxiliary/plugin-information/locale-messages/useLocaleMessages'; declare const window: PluginBrowserWindow; @@ -125,16 +124,9 @@ export abstract class BbbPluginSdk { eventName, payload, ); - pluginApi.persistAsset = ( - assetUrl: string, - typeOfAsset: AssetType, - assetName?: string, - ) => persistAssetFunctionWrapper( - pluginName, - assetUrl, - typeOfAsset, - assetName, - ); + pluginApi.useLocaleMessages = ( + fetchConfigs?: RequestInit, + ) => useLocaleMessagesAuxiliary({ pluginApi, fetchConfigs }); } else { throw new Error('Plugin name not set'); } diff --git a/src/core/api/types.ts b/src/core/api/types.ts index 7ca76d56..e050e465 100644 --- a/src/core/api/types.ts +++ b/src/core/api/types.ts @@ -32,7 +32,7 @@ import { UseUserCameraDomElementsFunction } from '../../dom-element-manipulation import { ScreenshareHelperInterface, UserCameraHelperInterface } from '../../extensible-areas'; import { GetDataSource } from '../../remote-data/types'; import { PersistEventFunction } from '../../event-persistence/types'; -import { PersistAssetFunction } from '../../asset-persistence/types'; +import { UseLocaleMessagesFunction } from '../auxiliary/plugin-information/locale-messages/types'; // Setter Functions for the API export type SetPresentationToolbarItems = (presentationToolbarItem: @@ -238,6 +238,13 @@ export interface PluginApi { // --- Auxiliary functions --- getSessionToken?: GetSessionTokenFunction; getJoinUrl?: GetJoinUrlFunction; + /** + * Return messages to be used in the internacionalization functions (react-intl is recommended) + * + * @param fetchConfigs - fetch configuration object for the locale files (otional, + * usefull in dev environments). + */ + useLocaleMessages?: UseLocaleMessagesFunction /** * Send data to the Learning analytics dashboard * @@ -260,13 +267,6 @@ export interface PluginApi { * */ persistEvent?: PersistEventFunction; - /** - * Persists assets to the current meeting, e.g.: presentation. - * - * @param payload - payload to be persisted in `events.xml` - * - */ - persistAsset?: PersistAssetFunction; } export interface PluginBrowserWindow extends Window { diff --git a/src/core/auxiliary/plugin-information/locale-messages/subscriptions.ts b/src/core/auxiliary/plugin-information/locale-messages/subscriptions.ts new file mode 100644 index 00000000..4ca2697a --- /dev/null +++ b/src/core/auxiliary/plugin-information/locale-messages/subscriptions.ts @@ -0,0 +1,12 @@ +const GET_PLUGIN_INFORMATION = ` +subscription GetPluginInformation { + plugin { + javascriptEntrypointIntegrity + javascriptEntrypointUrl + localesBaseUrl + name + } +} +`; + +export { GET_PLUGIN_INFORMATION }; diff --git a/src/core/auxiliary/plugin-information/locale-messages/types.ts b/src/core/auxiliary/plugin-information/locale-messages/types.ts new file mode 100644 index 00000000..89cefbea --- /dev/null +++ b/src/core/auxiliary/plugin-information/locale-messages/types.ts @@ -0,0 +1,32 @@ +import { PluginApi } from 'src/core/api/types'; + +interface UseLocaleMessagesProps { + pluginApi: PluginApi; + fetchConfigs?: RequestInit; +} + +interface PluginInformationResult { + javascriptEntrypointIntegrity: string; + javascriptEntrypointUrl: string; + localesBaseUrl: string; +} + +interface GraphqlResponseWrapper { + plugin: PluginInformationResult[]; +} + +interface IntlMessages { + loading: boolean; + messages: Record; + currentLocale: string; +} + +type UseLocaleMessagesFunction = (fetchConfigs?: RequestInit) => IntlMessages; + +export { + UseLocaleMessagesProps, + PluginInformationResult, + GraphqlResponseWrapper, + IntlMessages, + UseLocaleMessagesFunction, +}; diff --git a/src/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.ts b/src/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.ts new file mode 100644 index 00000000..7db70538 --- /dev/null +++ b/src/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.ts @@ -0,0 +1,43 @@ +import * as React from 'react'; +import { IntlLocaleUiDataNames } from '../../../../ui-data-hooks'; +import { pluginLogger } from '../../../../utils'; +import { GraphqlResponseWrapper, IntlMessages, UseLocaleMessagesProps } from './types'; +import { GET_PLUGIN_INFORMATION } from './subscriptions'; + +function useLocaleMessagesAuxiliary( + { pluginApi, fetchConfigs }: UseLocaleMessagesProps, +): IntlMessages { + const currentLocale = pluginApi.useUiData!(IntlLocaleUiDataNames.CURRENT_LOCALE, { + locale: 'en', + fallbackLocale: 'en', + }); + + const [loading, setLoading] = React.useState(true); + const [messages, setMessages] = React.useState>({}); + + const { data: pluginInformation } = pluginApi.useCustomSubscription!( + GET_PLUGIN_INFORMATION, + ); + + React.useEffect(() => { + if (pluginInformation && pluginInformation.plugin && currentLocale.locale) { + const { localesBaseUrl } = pluginInformation.plugin[0]; + const { locale } = currentLocale; + const localeUrl = `${localesBaseUrl}/${locale}.json`; + fetch(localeUrl, fetchConfigs).then((result) => result.json()).then((localeMessages) => { + setLoading(false); + setMessages(localeMessages); + }).catch((err) => { + setLoading(false); + pluginLogger.error(`Something went wrong while trying to fetch ${localeUrl}: `, err); + }); + } + }, [pluginInformation, currentLocale]); + return { + messages, + loading, + currentLocale: currentLocale.locale, + }; +} + +export default useLocaleMessagesAuxiliary; diff --git a/src/data-consumption/domain/settings/plugin-settings/utils.ts b/src/data-consumption/domain/settings/plugin-settings/utils.ts index d6654f30..8586fd6d 100644 --- a/src/data-consumption/domain/settings/plugin-settings/utils.ts +++ b/src/data-consumption/domain/settings/plugin-settings/utils.ts @@ -5,7 +5,7 @@ export const filterPluginSpecificSettings = ( completeSettings: GraphqlResponseWrapper, ) => { const pluginSettings = completeSettings - .data?.meeting_clientPluginSettings[0].settings; + .data?.meeting_clientPluginSettings[0]?.settings; return { ...completeSettings, data: pluginSettings, diff --git a/src/data-consumption/domain/users/current-user/types.ts b/src/data-consumption/domain/users/current-user/types.ts index 192a1184..8548b609 100644 --- a/src/data-consumption/domain/users/current-user/types.ts +++ b/src/data-consumption/domain/users/current-user/types.ts @@ -1,10 +1,16 @@ import { GraphqlResponseWrapper } from '../../../../core'; +export interface Camera { + streamId: string; +} + export interface CurrentUserData { userId: string; + extId: string; name: string; role: string; - presenter: boolean + presenter: boolean; + cameras: Camera[]; } export type UseCurrentUserFunction = () => GraphqlResponseWrapper | undefined; diff --git a/src/ui-commands/camera/commands.ts b/src/ui-commands/camera/commands.ts new file mode 100644 index 00000000..a55be81c --- /dev/null +++ b/src/ui-commands/camera/commands.ts @@ -0,0 +1,52 @@ +import { CameraEnum } from './enums'; +import { SetSelfViewDisableAllDevicesCommandArguments, SetSelfViewDisableCommandArguments } from './types'; + +export const camera = { + /** + * Sets the self-view camera disabled/enabled for all cameras. + * + * @param setSelfViewDisableAllDevicesCommandArguments: object with a + * boolean that tells whether to enable or not the self-view camera for all devices + */ + setSelfViewDisableAllDevices: ( + setSelfViewDisableAllDevicesCommandArguments: SetSelfViewDisableAllDevicesCommandArguments, + ) => { + const { + isSelfViewDisabledAllDevices, + } = setSelfViewDisableAllDevicesCommandArguments; + window.dispatchEvent( + new CustomEvent< + SetSelfViewDisableAllDevicesCommandArguments + >(CameraEnum.SET_SELF_VIEW_DISABLED_ALL_DEVICES, { + detail: { + isSelfViewDisabledAllDevices, + }, + }), + ); + }, + + /** + * Sets the self-view camera disabled/enabled for specific camera. + * + * @param setSelfViewDisableCommandArguments: object with a + * boolean that tells whether to enable or not the self-view camera for specific device + */ + setSelfViewDisable: ( + setSelfViewDisableCommandArguments: SetSelfViewDisableCommandArguments, + ) => { + const { + isSelfViewDisabled, + streamId, + } = setSelfViewDisableCommandArguments; + window.dispatchEvent( + new CustomEvent< + SetSelfViewDisableCommandArguments + >(CameraEnum.SET_SELF_VIEW_DISABLED, { + detail: { + isSelfViewDisabled, + streamId, + }, + }), + ); + }, +}; diff --git a/src/ui-commands/camera/enums.ts b/src/ui-commands/camera/enums.ts new file mode 100644 index 00000000..875069b2 --- /dev/null +++ b/src/ui-commands/camera/enums.ts @@ -0,0 +1,4 @@ +export enum CameraEnum { + SET_SELF_VIEW_DISABLED_ALL_DEVICES = 'SET_SELF_VIEW_DISABLED_ALL_DEVICES_COMMAND', + SET_SELF_VIEW_DISABLED = 'SET_SELF_VIEW_DISABLED_COMMAND', +} diff --git a/src/ui-commands/camera/types.ts b/src/ui-commands/camera/types.ts new file mode 100644 index 00000000..2c130feb --- /dev/null +++ b/src/ui-commands/camera/types.ts @@ -0,0 +1,17 @@ +export interface SetSelfViewDisableAllDevicesCommandArguments { + isSelfViewDisabledAllDevices: boolean; +} + +export interface SetSelfViewDisableCommandArguments { + isSelfViewDisabled: boolean; + streamId: string; +} + +export interface UiCommandsCameraObject { + setSelfViewDisableAllDevices: ( + setSelfViewDisableAllDevicesCommandArguments: SetSelfViewDisableAllDevicesCommandArguments + ) => void; + setSelfViewDisable: ( + setSelfViewDisableAllDevicesCommandArguments: SetSelfViewDisableCommandArguments + ) => void; +} diff --git a/src/ui-commands/commands.ts b/src/ui-commands/commands.ts index 0bea491b..7b7c2730 100644 --- a/src/ui-commands/commands.ts +++ b/src/ui-commands/commands.ts @@ -5,12 +5,14 @@ import { presentationArea } from './presentation-area/commands'; import { userStatus } from './user-status/commands'; import { conference } from './conference/commands'; import { notification } from './notification/commands'; +import { camera } from './camera/commands'; import { actionsBar } from './actions-bar/commands'; import { layout } from './layout/commands'; import { navBar } from './nav-bar/commands'; export const uiCommands = { actionsBar, + camera, chat, externalVideo, sidekickOptionsContainer, diff --git a/src/ui-commands/notification/commands.ts b/src/ui-commands/notification/commands.ts index 07ebbefe..f9b819bc 100644 --- a/src/ui-commands/notification/commands.ts +++ b/src/ui-commands/notification/commands.ts @@ -1,5 +1,5 @@ import { NotificationEnum } from './enums'; -import { SendNotificationCommandArguments } from './types'; +import { SendNotificationCommandArguments, SetEnableDisplayNotificationsArguments } from './types'; export const notification = { /** @@ -14,4 +14,16 @@ export const notification = { }), ); }, + /** + * Decides if notifications stop being displayed. + */ + setEnabledDisplayNotifications: (isNotificationDisplayEnabled: boolean) => { + window.dispatchEvent( + new CustomEvent< + SetEnableDisplayNotificationsArguments + >(NotificationEnum.SET_ENABLED_DISPLAY, { + detail: { isNotificationDisplayEnabled }, + }), + ); + }, }; diff --git a/src/ui-commands/notification/enums.ts b/src/ui-commands/notification/enums.ts index 1d4519d3..7052d607 100644 --- a/src/ui-commands/notification/enums.ts +++ b/src/ui-commands/notification/enums.ts @@ -1,5 +1,6 @@ export enum NotificationEnum { - SEND = 'SEND_NOTIFICATION', + SEND = 'SEND_NOTIFICATION_COMMAND', + SET_ENABLED_DISPLAY = 'SET_ENABLED_DISPLAY_COMMAND' } export enum NotificationTypeUiCommand { diff --git a/src/ui-commands/notification/types.ts b/src/ui-commands/notification/types.ts index 8159c8f0..6bb25427 100644 --- a/src/ui-commands/notification/types.ts +++ b/src/ui-commands/notification/types.ts @@ -15,6 +15,11 @@ export interface SendNotificationCommandArguments { small?: boolean; } +export interface SetEnableDisplayNotificationsArguments { + isNotificationDisplayEnabled: boolean; +} + export interface UiCommandsNotificationObject { send: (information: SendNotificationCommandArguments) => void; + setEnabledDisplayNotifications: (isNotificationDisplayEnabled: boolean) => void; } diff --git a/src/ui-commands/types.ts b/src/ui-commands/types.ts index 2244bd3a..ae016ba0 100644 --- a/src/ui-commands/types.ts +++ b/src/ui-commands/types.ts @@ -8,10 +8,12 @@ import { UiCommandsNotificationObject } from './notification/types'; import { UiCommandsActionsBarObject } from './actions-bar/types'; import { UiCommandsLayoutObject } from './layout/types'; import { UiCommandsNavBarObject } from './nav-bar/types'; +import { UiCommandsCameraObject } from './camera/types'; export interface UiCommands { layout: UiCommandsLayoutObject; actionsBar: UiCommandsActionsBarObject; + camera: UiCommandsCameraObject; chat: UiCommandsChatObject; externalVideo: UiCommandsExternalVideoObject; sidekickOptionsContainer: UiCommandsSidekickOptionsContainerObject;