small ui tweaks

This commit is contained in:
x032205
2025-05-05 16:07:04 -04:00
parent dc59f226b6
commit 86bb2659b5
@@ -14,7 +14,7 @@ export const CachingPanel = () => {
const { mutateAsync: invalidateCache } = useInvalidateCache(); const { mutateAsync: invalidateCache } = useInvalidateCache();
const { membership } = useOrgPermission(); const { membership } = useOrgPermission();
const hasShownSuccessRef = useRef(true); const shouldShowSuccessRef = useRef(false);
const timeoutRef = useRef<NodeJS.Timeout | null>(null); const timeoutRef = useRef<NodeJS.Timeout | null>(null);
const [type, setType] = useState<CacheType | null>(null); const [type, setType] = useState<CacheType | null>(null);
@@ -34,8 +34,8 @@ export const CachingPanel = () => {
}; };
const success = () => { const success = () => {
if (hasShownSuccessRef.current) return; if (!shouldShowSuccessRef.current) return;
hasShownSuccessRef.current = true; shouldShowSuccessRef.current = false;
createNotification({ text: "Successfully invalidated cache", type: "success" }); createNotification({ text: "Successfully invalidated cache", type: "success" });
setButtonsDisabled(false); setButtonsDisabled(false);
@@ -45,7 +45,7 @@ export const CachingPanel = () => {
const handleInvalidateCacheSubmit = async () => { const handleInvalidateCacheSubmit = async () => {
if (!type) return; if (!type) return;
hasShownSuccessRef.current = false; shouldShowSuccessRef.current = true;
try { try {
await invalidateCache({ type }); await invalidateCache({ type });
@@ -67,8 +67,11 @@ export const CachingPanel = () => {
useEffect(() => { useEffect(() => {
refetchInvalidatingStatus(); refetchInvalidatingStatus();
const timer = setTimeout(() => (hasShownSuccessRef.current = false), 1000); const timer = setTimeout(() => (shouldShowSuccessRef.current = true), 1000);
return () => clearTimeout(timer); return () => {
clearTimeout(timer);
setShouldPoll(false);
};
}, []); }, []);
useEffect(() => { useEffect(() => {
@@ -84,7 +87,7 @@ export const CachingPanel = () => {
}, [isInvalidating]); }, [isInvalidating]);
useEffect(() => { useEffect(() => {
if (!hasShownSuccessRef.current && isInvalidating === false) { if (shouldShowSuccessRef.current && isInvalidating === false) {
success(); success();
clearTimeout(timeoutRef.current!); clearTimeout(timeoutRef.current!);
} }