mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
* 🔧 refactor: Improve accessibility and styling in ChatGroupItem and FilterPrompts components * 🔧 fix: Add button type and keyboard accessibility to dropdown menu trigger in ChatGroupItem * 🔧 fix(757): Enhance accessibility by updating aria-labels and adding localization for prompt groups * 🔧 fix(618): Update version to 0.3.1 and enhance accessibility in InfoHoverCard component * 🔧 fix(618): Update aria-label in InfoHoverCard to use dynamic text prop for improved accessibility * 🔧 fix: Enhance accessibility by updating aria-labels and roles in Conversations components * 🔧 fix(620): Enhance accessibility by adding tabIndex to Tabs.Content components in ArtifactTabs, Settings, and Speech components * refactor: remove RevokeKeysButton component and update related components for accessibility - Deleted RevokeKeysButton component. - Updated SharedLinks and General components to use Label for accessibility. - Enhanced Personalization component with aria-labelledby and aria-describedby attributes. - Refactored ConversationModeSwitch to use ToggleSwitch for better state management. - Improved AutoSendTextSelector with local state management and accessibility attributes. - Replaced Switch components with ToggleSwitch in various Speech and TTS components for consistency. - Added aria-labelledby attributes to Dropdown components for better accessibility. - Updated translation.json to include new localization keys and improved existing ones. - Enhanced Slider component to support aria attributes for better accessibility. * 🔧 fix: Enhance user feedback for API key operations with success and error messages * 🔧 fix: Update aria-labels in Avatar component for improved localization and accessibility * 🔧 fix: Refactor handleFile and handleDrop functions for improved readability and maintainability
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import React, { useState, useCallback, useRef, useEffect } from 'react';
|
|
import {
|
|
OGDialogTemplate,
|
|
Label,
|
|
Button,
|
|
OGDialog,
|
|
OGDialogTrigger,
|
|
Spinner,
|
|
useOnClickOutside,
|
|
} from '@librechat/client';
|
|
import { useLocalize } from '~/hooks';
|
|
|
|
export const DeleteCache = ({ disabled = false }: { disabled?: boolean }) => {
|
|
const localize = useLocalize();
|
|
const [open, setOpen] = useState(false);
|
|
const [isCacheEmpty, setIsCacheEmpty] = useState(true);
|
|
const [confirmClear, setConfirmClear] = useState(false);
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
const contentRef = useRef(null);
|
|
useOnClickOutside(contentRef, () => confirmClear && setConfirmClear(false), []);
|
|
|
|
const checkCache = useCallback(async () => {
|
|
const cache = await caches.open('tts-responses');
|
|
const keys = await cache.keys();
|
|
setIsCacheEmpty(keys.length === 0);
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
checkCache();
|
|
}, [checkCache]);
|
|
|
|
const revokeAllUserKeys = useCallback(async () => {
|
|
setIsLoading(true);
|
|
const cache = await caches.open('tts-responses');
|
|
await cache.keys().then((keys) => Promise.all(keys.map((key) => cache.delete(key))));
|
|
setIsLoading(false);
|
|
}, []);
|
|
|
|
return (
|
|
<div className="flex items-center justify-between">
|
|
<Label id="delete-cache-label">{localize('com_nav_delete_cache_storage')}</Label>
|
|
<OGDialog open={open} onOpenChange={setOpen}>
|
|
<OGDialogTrigger asChild>
|
|
<Button
|
|
variant="destructive"
|
|
onClick={() => setOpen(true)}
|
|
disabled={disabled || isCacheEmpty}
|
|
aria-labelledby="delete-cache-label"
|
|
>
|
|
{localize('com_ui_delete')}
|
|
</Button>
|
|
</OGDialogTrigger>
|
|
<OGDialogTemplate
|
|
showCloseButton={false}
|
|
title={localize('com_nav_confirm_clear')}
|
|
className="max-w-[450px]"
|
|
main={
|
|
<Label className="text-left text-sm font-medium">
|
|
{localize('com_nav_clear_cache_confirm_message')}
|
|
</Label>
|
|
}
|
|
selection={{
|
|
selectHandler: revokeAllUserKeys,
|
|
selectClasses:
|
|
'bg-destructive text-white transition-all duration-200 hover:bg-destructive/80',
|
|
selectText: isLoading ? <Spinner /> : localize('com_ui_delete'),
|
|
}}
|
|
/>
|
|
</OGDialog>
|
|
</div>
|
|
);
|
|
};
|