forked from React-Group/interstellar_ai
radio selection still broken will come back to that later
This commit is contained in:
parent
d0ebe2d79a
commit
7c77e43be8
2 changed files with 29 additions and 10 deletions
|
@ -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<PrivacySettingsProps> = ({ 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 */}
|
||||
<div className="settings-option">
|
||||
<p>Disable Options:</p>
|
||||
<p>{openSourceMode ? 'Disable Options (FOSS Mode):' : 'Disable Options:'}</p>
|
||||
<div className="slider">
|
||||
{/* Offline */}
|
||||
<div
|
||||
className={`slider-option ${selectedOption === 'Offline' ? 'active' : ''}`}
|
||||
onClick={() => handleRadioChange('Offline')} // Allow selection only if not in open-source mode
|
||||
onClick={() => handleOptionClick('Offline')}
|
||||
>
|
||||
Offline tools{openSourceMode ? ' (FOSS)' : ''}
|
||||
</div>
|
||||
|
||||
{/* Online */}
|
||||
{/* Online (Available even in FOSS mode) */}
|
||||
<div
|
||||
className={`slider-option ${selectedOption === 'Online' ? 'active' : ''}`}
|
||||
onClick={() => handleRadioChange('Online')}
|
||||
onClick={() => handleOptionClick('Online')}
|
||||
>
|
||||
Online tools{openSourceMode ? ' (FOSS)' : ''}
|
||||
</div>
|
||||
|
@ -33,7 +45,7 @@ const PrivacySettings: React.FC<PrivacySettingsProps> = ({ selectedOption, handl
|
|||
{/* None */}
|
||||
<div
|
||||
className={`slider-option ${selectedOption === 'None' ? 'active' : ''}`}
|
||||
onClick={() => handleRadioChange('None')}
|
||||
onClick={() => handleOptionClick('None')}
|
||||
>
|
||||
None{openSourceMode ? ' (FOSS)' : ''}
|
||||
</div>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
|
Loading…
Reference in a new issue