plugin updates

This commit is contained in:
Tony Volpe
2024-06-17 15:33:26 -04:00
parent 3751a5a1a6
commit e4e274a9a7
2674 changed files with 0 additions and 507851 deletions

View File

@@ -1,45 +0,0 @@
import { useEffect, useState } from 'react';
import { usePostAsyncBackgroundMessage } from '../../../iframe/useBackgroundApp';
import LoadState, { LoadStateType } from '../../enums/loadState';
import { ProxyMessages } from '../../../iframe/integratedMessages';
let user: any = null;
export default function useCurrentUserFetch() {
const proxy = usePostAsyncBackgroundMessage();
const [loadState, setLoadState] = useState<LoadStateType>(
LoadState.NotLoaded
);
const [error, setError] = useState<null | Error>(null);
const createUser = () => {
if (!user) {
setLoadState(LoadState.NotLoaded);
}
};
const reload = () => {
user = null;
setLoadState(LoadState.NotLoaded);
setError(null);
};
useEffect(() => {
if (loadState === LoadState.NotLoaded && !user) {
setLoadState(LoadState.Loading);
proxy({
key: ProxyMessages.FetchOrCreateMeetingUser,
})
.then(data => {
user = data;
setLoadState(LoadState.Idle);
})
.catch(err => {
setError(err);
setLoadState(LoadState.Failed);
});
}
}, [loadState]);
return { user, loadUserState: loadState, error, createUser, reload };
}