From 93205fb2dbc0a8be26d7d747e040cee2ee63991d Mon Sep 17 00:00:00 2001 From: Nevo David Date: Wed, 7 May 2025 22:17:19 +0700 Subject: [PATCH] feat: quick hook to solve the delay problem in reposts --- .../components/launches/internal.channels.tsx | 16 +++++++++++----- .../launches/providers/high.order.provider.tsx | 4 +++- eslint.config.mjs | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/frontend/src/components/launches/internal.channels.tsx b/apps/frontend/src/components/launches/internal.channels.tsx index 02837631..ec966bb4 100644 --- a/apps/frontend/src/components/launches/internal.channels.tsx +++ b/apps/frontend/src/components/launches/internal.channels.tsx @@ -87,14 +87,16 @@ const Plug: FC<{ }> = ({ plug }) => { const { allIntegrations, integration } = useIntegration(); const { watch, setValue, control, register } = useSettings(); + const [load, setLoad] = useState(false); const val = watch(`plug--${plug.identifier}--integrations`); const active = watch(`plug--${plug.identifier}--active`); - // const selectedIntegrationsValue = watch( - // `plug.${plug.identifier}.integrations` - // ); - // - // console.log(selectedIntegrationsValue); + useEffect(() => { + setTimeout(() => { + setLoad(true); + }, 20); + }, []); + const [localValue, setLocalValue] = useState( (val || []).map((p: any) => ({ ...p })) ); @@ -109,6 +111,10 @@ const Plug: FC<{ ) ); + if (!load) { + return null; + } + return (
( ).json(); }, [props.identifier]); - const { data } = useSWR(`internal-${props.identifier}`, getInternalPlugs); + const { data } = useSWR(`internal-${props.identifier}`, getInternalPlugs, { + revalidateOnReconnect: true, + }); // this is a trick to prevent the data from being deleted, yet we don't render the elements if (!props.show) { diff --git a/eslint.config.mjs b/eslint.config.mjs index 746467c9..d7773cf2 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -20,6 +20,7 @@ const eslintConfig = [ "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/no-empty-object-type": "off", "@typescript-eslint/prefer-as-const": "off", + "@typescript-eslint/no-non-null-asserted-optional-chain": "off" }, }), ];