enhance globalComponentInstanceContextMap type safety (#13544)
Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@@ -1,10 +1,3 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
_env_?: Record<string, string>;
|
||||
__APOLLO_CLIENT__?: any;
|
||||
}
|
||||
}
|
||||
|
||||
const getDefaultUrl = () => {
|
||||
if (
|
||||
window.location.hostname === 'localhost' ||
|
||||
|
||||
@@ -7,13 +7,6 @@ import { captchaState } from '@/client-config/states/captchaState';
|
||||
import { CaptchaDriverType } from '~/generated-metadata/graphql';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
grecaptcha?: any;
|
||||
turnstile?: any;
|
||||
}
|
||||
}
|
||||
|
||||
export const useRequestFreshCaptchaToken = () => {
|
||||
const setCaptchaToken = useSetRecoilState(captchaTokenState);
|
||||
const setIsRequestingCaptchaToken = useSetRecoilState(
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
declare interface Window {
|
||||
FrontChat?: (method: string, ...args: any[]) => void;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { ComponentInstanceStateContext } from '@/ui/utilities/state/component-state/types/ComponentInstanceStateContext';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
_env_?: Record<string, string>;
|
||||
__APOLLO_CLIENT__?: any;
|
||||
grecaptcha?: any;
|
||||
turnstile?: any;
|
||||
componentComponentStateContextMap: Map<
|
||||
string,
|
||||
ComponentInstanceStateContext<any>
|
||||
>;
|
||||
FrontChat?: (method: string, ...args: any[]) => void;
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -3,17 +3,18 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
class ComponentInstanceContextMap {
|
||||
constructor() {
|
||||
if (!isDefined((window as any).componentComponentStateContextMap)) {
|
||||
(window as any).componentComponentStateContextMap = new Map();
|
||||
if (!isDefined(window.componentComponentStateContextMap)) {
|
||||
window.componentComponentStateContextMap = new Map();
|
||||
}
|
||||
}
|
||||
|
||||
public get(key: string): ComponentInstanceStateContext<any> {
|
||||
return (window as any).componentComponentStateContextMap.get(key);
|
||||
public get(key: string): ComponentInstanceStateContext<any> | undefined {
|
||||
const context = window.componentComponentStateContextMap.get(key);
|
||||
return context;
|
||||
}
|
||||
|
||||
public set(key: string, context: ComponentInstanceStateContext<any>) {
|
||||
(window as any).componentComponentStateContextMap.set(key, context);
|
||||
window.componentComponentStateContextMap.set(key, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
_env_?: Record<string, string>;
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -1,10 +1,3 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
_env_?: Record<string, string>;
|
||||
__APOLLO_CLIENT__?: any;
|
||||
}
|
||||
}
|
||||
|
||||
const getDefaultUrl = () => {
|
||||
if (
|
||||
window.location.hostname === 'localhost' ||
|
||||
|
||||
Reference in New Issue
Block a user