From 7c77e43be812f54a61fc59071b38ce4cddac7ce3 Mon Sep 17 00:00:00 2001 From: sageTheDM Date: Thu, 3 Oct 2024 14:38:56 +0200 Subject: [PATCH] radio selection still broken will come back to that later --- app/components/settings/PrivacySettings.tsx | 26 +++++++++++++++------ app/components/settings/Settings.tsx | 13 ++++++++--- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/app/components/settings/PrivacySettings.tsx b/app/components/settings/PrivacySettings.tsx index e9cab20..49dc680 100644 --- a/app/components/settings/PrivacySettings.tsx +++ b/app/components/settings/PrivacySettings.tsx @@ -1,5 +1,4 @@ -// PrivacySettings.tsx -import React from 'react'; +import React, { useEffect } from 'react'; interface PrivacySettingsProps { selectedOption: string; // The currently selected option @@ -8,24 +7,37 @@ interface PrivacySettingsProps { } const PrivacySettings: React.FC = ({ selectedOption, handleRadioChange, openSourceMode }) => { + + // Set default option based on openSourceMode if no option is selected + useEffect(() => { + if (!selectedOption) { + handleRadioChange(openSourceMode ? 'Offline' : 'None'); + } + }, [selectedOption, handleRadioChange, openSourceMode]); + + // Handle option click and allow all options, even in open-source mode + const handleOptionClick = (option: string) => { + handleRadioChange(option); // No restrictions on options + }; + return ( <> {/* AI Mode Radio Options */}
-

Disable Options:

+

{openSourceMode ? 'Disable Options (FOSS Mode):' : 'Disable Options:'}

{/* Offline */}
handleRadioChange('Offline')} // Allow selection only if not in open-source mode + onClick={() => handleOptionClick('Offline')} > Offline tools{openSourceMode ? ' (FOSS)' : ''}
- {/* Online */} + {/* Online (Available even in FOSS mode) */}
handleRadioChange('Online')} + onClick={() => handleOptionClick('Online')} > Online tools{openSourceMode ? ' (FOSS)' : ''}
@@ -33,7 +45,7 @@ const PrivacySettings: React.FC = ({ selectedOption, handl {/* None */}
handleRadioChange('None')} + onClick={() => handleOptionClick('None')} > None{openSourceMode ? ' (FOSS)' : ''}
diff --git a/app/components/settings/Settings.tsx b/app/components/settings/Settings.tsx index e55657f..7b752d7 100644 --- a/app/components/settings/Settings.tsx +++ b/app/components/settings/Settings.tsx @@ -56,7 +56,14 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = ( const [timeZone, setTimeZone] = useState(() => localStorage.getItem('timeZone') || 'GMT'); // Online AI and chat history settings - const [selectedOption, setSelectedOption] = useState('Offline'); // Default to 'Offline' + const [selectedOption, setSelectedOption] = useState(() => { + // Check if openSourceMode exists in localStorage + const openSourceMode = localStorage.getItem("openSourceMode"); + + // If it exists and is "true", set selectedOption to None (Foss), otherwise set it to None + return openSourceMode === "true" ? "None (FOSS)" : "None"; + }); + const [disableChatHistory, setDisableChatHistory] = useState(() => getItemFromLocalStorage('disableChatHistory')); const [disableAIMemory, setDisableAIMemory] = useState(() => getItemFromLocalStorage('disableAIMemory')); const [openSourceMode, setOpenSourceMode] = useState(() => getItemFromLocalStorage('openSourceMode')); @@ -110,7 +117,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = ( const [primaryColor, setPrimaryColor] = useState(localStorage.getItem("primaryColor") || "#dc8add"); const [secondaryColor, setSecondaryColor] = useState(localStorage.getItem("secondaryColor") || "#c061cb"); const [accentColor, setAccentColor] = useState(localStorage.getItem("accentColor") || "#9141ac"); - const [basicBackgroundColor, setBasicBackgroundColor] = useState(localStorage.getItem("basicBackgroundColor") || "##813d9c"); + const [basicBackgroundColor, setBasicBackgroundColor] = useState(localStorage.getItem("basicBackgroundColor") || "#813d9c"); const [basicTextColor, setBasicTextColor] = useState(localStorage.getItem("basicTextColor") || "#fefefe"); // Theme selection @@ -331,7 +338,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = ( useEffect(() => { const savedOption = localStorage.getItem('radioSelection'); if (savedOption) { - setSelectedOption(savedOption); // Set saved selection + handleRadioChange(savedOption); // Set saved selection } }, []);