Merge pull request 'cool pull' (#82) from sageTheDm/interstellar_ai:main into main

Reviewed-on: https://interstellardevelopment.org/code/code/React-Group/interstellar_ai/pulls/82
This commit is contained in:
Patrick 2024-10-02 08:26:06 +02:00
commit 40ad1e990d

View file

@ -174,9 +174,18 @@ const Models: React.FC = () => {
const [currentCategory, setCurrentCategory] = useState(localStorage.getItem("activeCategory")); const [currentCategory, setCurrentCategory] = useState(localStorage.getItem("activeCategory"));
useEffect(() => { useEffect(() => {
// Retrieve initial values from localStorage if (!localStorage.getItem('selectedModel')) {
setRadioSelection(localStorage.getItem('radioSelection') || ''); localStorage.setItem("selectedModel", "Offline Fast" )
setSelectedModel(localStorage.getItem('selectedModel') || ''); }
if (!localStorage.getItem("activeCategory")) {
setActiveCategory('Code')
localStorage.setItem('activeCategory' ,'Code')
}
if (!localStorage.getItem("model")) {
localStorage.setItem("model" ,'starcoder2')
}
const handleStorageChange = () => { const handleStorageChange = () => {
setSelectedModel(localStorage.getItem('selectedModel') || ''); setSelectedModel(localStorage.getItem('selectedModel') || '');
@ -185,6 +194,8 @@ const Models: React.FC = () => {
// Update immediately when localStorage changes // Update immediately when localStorage changes
window.addEventListener('storage', handleStorageChange); window.addEventListener('storage', handleStorageChange);
setRadioSelection(localStorage.getItem('radioSelection') || '');
setSelectedModel(localStorage.getItem('selectedModel') || '');
// Cleanup listener on component unmount // Cleanup listener on component unmount
return () => { return () => {
window.removeEventListener('storage', handleStorageChange); window.removeEventListener('storage', handleStorageChange);