The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/apps/client/gameCenter/tabBar.ts

28 lines
991 B

import { useMemo } from 'react';
import { useSetting } from '../../../../client/contexts/SettingsContext';
import { addAction } from '../../../../client/views/room/lib/Toolbox';
import { useEndpointData } from '../../../../client/hooks/useEndpointData';
import { AsyncStatePhase } from '../../../../client/hooks/useAsyncState';
addAction('game-center', () => {
const enabled = useSetting('Apps_Game_Center_enabled');
const { value = { externalComponents: [] }, phase: state, error } = useEndpointData('/apps/externalComponents');
const hasExternalComponents = value && value.externalComponents.length > 0;
const hasError = !!error;
return useMemo(() =>
(enabled
&& state === AsyncStatePhase.RESOLVED
&& !hasError
&& hasExternalComponents
? {
groups: ['channel', 'group', 'direct'],
id: 'game-center',
title: 'Apps_Game_Center',
icon: 'game',
template: 'GameCenter',
order: -1,
} : null), [enabled, hasError, hasExternalComponents, state]);
});