bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/components-data/userGrapQlMiniMongoAdapter/component.tsx
Tainan Felipe 3bc40df230
Add: useDeduplicatedSubscription hook (#20376)
* Add: useDeduplicatedSubscription hook

* Fix: TS error

* Add: components using useDeduplicatedSubscription

* Change: Move to useDeduplicatedSubscription

* Change: unsubscribe logic to own useEffect

* Change: remove file import over package

* Fix: TS errors

* Fix: private chat not loading

* Change: revert changes on queries

* Fix: eslint error

* Remove: html-webpack-plugin package

* Fix: external video

* Add: comment about the stringToHash function

* Fix: video player showing tools over presentation
2024-06-04 10:40:54 -03:00

41 lines
1.0 KiB
TypeScript

import React, { useEffect, useRef, useState } from 'react';
import Users from '/imports/api/users';
import logger from '/imports/startup/client/logger';
import { AdapterProps } from '../graphqlToMiniMongoAdapterManager/component';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
const UserGrapQlMiniMongoAdapter: React.FC<AdapterProps> = ({
onReady,
children,
}) => {
const ready = useRef(false);
const {
data,
errors: error,
} = useCurrentUser((u) => u);
const [userDataSetted, setUserDataSetted] = useState(false);
useEffect(() => {
if (error) {
logger.error('Error in UserGrapQlMiniMongoAdapter', error);
}
}, [error]);
useEffect(() => {
if (data) {
if (!ready.current) {
ready.current = true;
onReady('UserGrapQlMiniMongoAdapter');
}
const { userId } = data;
Users.upsert({ userId }, data);
if (!userDataSetted) {
setUserDataSetted(true);
}
}
}, [data]);
return children;
};
export default UserGrapQlMiniMongoAdapter;