feat(custom-domains): allow to register a custom domain (without UI) (#9879)
# In this PR - Allow to register a custom domain - Refacto subdomain generation # In other PRs - Add UI to deal with a custom domain - Add logic to work with custom domain
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
import { useEffect } from 'react';
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { useGetHostnameDetailsQuery } from '~/generated/graphql';
|
||||
|
||||
export const SettingsHostnameEffect = () => {
|
||||
const { refetch } = useGetHostnameDetailsQuery();
|
||||
|
||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||
|
||||
useEffect(() => {
|
||||
let pollIntervalFn: null | ReturnType<typeof setInterval> = null;
|
||||
if (isDefined(currentWorkspace?.hostname)) {
|
||||
pollIntervalFn = setInterval(async () => {
|
||||
refetch();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (isDefined(pollIntervalFn)) {
|
||||
clearInterval(pollIntervalFn);
|
||||
}
|
||||
};
|
||||
}, [currentWorkspace?.hostname, refetch]);
|
||||
|
||||
return <></>;
|
||||
};
|
||||
Reference in New Issue
Block a user