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, { useEffect } from 'react';
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
interface PrivacySettingsProps {
|
interface PrivacySettingsProps {
|
||||||
selectedOption: string; // The currently selected option
|
selectedOption: string; // The currently selected option
|
||||||
|
@ -8,24 +7,37 @@ interface PrivacySettingsProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const PrivacySettings: React.FC<PrivacySettingsProps> = ({ selectedOption, handleRadioChange, openSourceMode }) => {
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* AI Mode Radio Options */}
|
{/* AI Mode Radio Options */}
|
||||||
<div className="settings-option">
|
<div className="settings-option">
|
||||||
<p>Disable Options:</p>
|
<p>{openSourceMode ? 'Disable Options (FOSS Mode):' : 'Disable Options:'}</p>
|
||||||
<div className="slider">
|
<div className="slider">
|
||||||
{/* Offline */}
|
{/* Offline */}
|
||||||
<div
|
<div
|
||||||
className={`slider-option ${selectedOption === 'Offline' ? 'active' : ''}`}
|
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)' : ''}
|
Offline tools{openSourceMode ? ' (FOSS)' : ''}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Online */}
|
{/* Online (Available even in FOSS mode) */}
|
||||||
<div
|
<div
|
||||||
className={`slider-option ${selectedOption === 'Online' ? 'active' : ''}`}
|
className={`slider-option ${selectedOption === 'Online' ? 'active' : ''}`}
|
||||||
onClick={() => handleRadioChange('Online')}
|
onClick={() => handleOptionClick('Online')}
|
||||||
>
|
>
|
||||||
Online tools{openSourceMode ? ' (FOSS)' : ''}
|
Online tools{openSourceMode ? ' (FOSS)' : ''}
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,7 +45,7 @@ const PrivacySettings: React.FC<PrivacySettingsProps> = ({ selectedOption, handl
|
||||||
{/* None */}
|
{/* None */}
|
||||||
<div
|
<div
|
||||||
className={`slider-option ${selectedOption === 'None' ? 'active' : ''}`}
|
className={`slider-option ${selectedOption === 'None' ? 'active' : ''}`}
|
||||||
onClick={() => handleRadioChange('None')}
|
onClick={() => handleOptionClick('None')}
|
||||||
>
|
>
|
||||||
None{openSourceMode ? ' (FOSS)' : ''}
|
None{openSourceMode ? ' (FOSS)' : ''}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -56,7 +56,14 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
||||||
const [timeZone, setTimeZone] = useState(() => localStorage.getItem('timeZone') || 'GMT');
|
const [timeZone, setTimeZone] = useState(() => localStorage.getItem('timeZone') || 'GMT');
|
||||||
|
|
||||||
// Online AI and chat history settings
|
// 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 [disableChatHistory, setDisableChatHistory] = useState(() => getItemFromLocalStorage('disableChatHistory'));
|
||||||
const [disableAIMemory, setDisableAIMemory] = useState(() => getItemFromLocalStorage('disableAIMemory'));
|
const [disableAIMemory, setDisableAIMemory] = useState(() => getItemFromLocalStorage('disableAIMemory'));
|
||||||
const [openSourceMode, setOpenSourceMode] = useState(() => getItemFromLocalStorage('openSourceMode'));
|
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 [primaryColor, setPrimaryColor] = useState(localStorage.getItem("primaryColor") || "#dc8add");
|
||||||
const [secondaryColor, setSecondaryColor] = useState(localStorage.getItem("secondaryColor") || "#c061cb");
|
const [secondaryColor, setSecondaryColor] = useState(localStorage.getItem("secondaryColor") || "#c061cb");
|
||||||
const [accentColor, setAccentColor] = useState(localStorage.getItem("accentColor") || "#9141ac");
|
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");
|
const [basicTextColor, setBasicTextColor] = useState(localStorage.getItem("basicTextColor") || "#fefefe");
|
||||||
|
|
||||||
// Theme selection
|
// Theme selection
|
||||||
|
@ -331,7 +338,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const savedOption = localStorage.getItem('radioSelection');
|
const savedOption = localStorage.getItem('radioSelection');
|
||||||
if (savedOption) {
|
if (savedOption) {
|
||||||
setSelectedOption(savedOption); // Set saved selection
|
handleRadioChange(savedOption); // Set saved selection
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue