mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-15 15:08:52 +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
90 lines
2.9 KiB
TypeScript
90 lines
2.9 KiB
TypeScript
import { useState, useEffect } from 'react';
|
|
import { Switch, useToastContext } from '@librechat/client';
|
|
import { useGetUserQuery, useUpdateMemoryPreferencesMutation } from '~/data-provider';
|
|
import { useLocalize } from '~/hooks';
|
|
|
|
interface PersonalizationProps {
|
|
hasMemoryOptOut: boolean;
|
|
hasAnyPersonalizationFeature: boolean;
|
|
}
|
|
|
|
export default function Personalization({
|
|
hasMemoryOptOut,
|
|
hasAnyPersonalizationFeature,
|
|
}: PersonalizationProps) {
|
|
const localize = useLocalize();
|
|
const { showToast } = useToastContext();
|
|
const { data: user } = useGetUserQuery();
|
|
const [referenceSavedMemories, setReferenceSavedMemories] = useState(true);
|
|
|
|
const updateMemoryPreferencesMutation = useUpdateMemoryPreferencesMutation({
|
|
onSuccess: () => {
|
|
showToast({
|
|
message: localize('com_ui_preferences_updated'),
|
|
status: 'success',
|
|
});
|
|
},
|
|
onError: () => {
|
|
showToast({
|
|
message: localize('com_ui_error_updating_preferences'),
|
|
status: 'error',
|
|
});
|
|
// Revert the toggle on error
|
|
setReferenceSavedMemories((prev) => !prev);
|
|
},
|
|
});
|
|
|
|
// Initialize state from user data
|
|
useEffect(() => {
|
|
if (user?.personalization?.memories !== undefined) {
|
|
setReferenceSavedMemories(user.personalization.memories);
|
|
}
|
|
}, [user?.personalization?.memories]);
|
|
|
|
const handleMemoryToggle = (checked: boolean) => {
|
|
setReferenceSavedMemories(checked);
|
|
updateMemoryPreferencesMutation.mutate({ memories: checked });
|
|
};
|
|
|
|
if (!hasAnyPersonalizationFeature) {
|
|
return (
|
|
<div className="flex flex-col gap-3 text-sm text-text-primary">
|
|
<div className="text-text-secondary">{localize('com_ui_no_personalization_available')}</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-col gap-3 text-sm text-text-primary">
|
|
{/* Memory Settings Section */}
|
|
{hasMemoryOptOut && (
|
|
<>
|
|
<div className="border-b border-border-medium pb-3">
|
|
<div className="text-base font-semibold">{localize('com_ui_memory')}</div>
|
|
</div>
|
|
|
|
<div className="flex items-center justify-between">
|
|
<div>
|
|
<div id="reference-saved-memories-label" className="flex items-center gap-2">
|
|
{localize('com_ui_reference_saved_memories')}
|
|
</div>
|
|
<div
|
|
id="reference-saved-memories-description"
|
|
className="mt-1 text-xs text-text-secondary"
|
|
>
|
|
{localize('com_ui_reference_saved_memories_description')}
|
|
</div>
|
|
</div>
|
|
<Switch
|
|
checked={referenceSavedMemories}
|
|
onCheckedChange={handleMemoryToggle}
|
|
disabled={updateMemoryPreferencesMutation.isLoading}
|
|
aria-labelledby="reference-saved-memories-label"
|
|
aria-describedby="reference-saved-memories-description"
|
|
/>
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|