feat: quick hook to solve the delay problem in reposts

This commit is contained in:
Nevo David 2025-05-07 22:17:19 +07:00
parent c161c3781a
commit 93205fb2db
3 changed files with 15 additions and 6 deletions

View File

@ -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<Integrations[]>(
(val || []).map((p: any) => ({ ...p }))
);
@ -109,6 +111,10 @@ const Plug: FC<{
)
);
if (!load) {
return null;
}
return (
<div
key={plug.title}

View File

@ -384,7 +384,9 @@ export const withProvider = function <T extends object>(
).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) {

View File

@ -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"
},
}),
];