feat: replace setting state using persisted hook
This commit is contained in:
parent
5d1e0a3599
commit
7fca553823
@ -21,6 +21,7 @@ import { Settings } from "./types";
|
|||||||
import { IS_RUNNING_ON_CLOUD } from "./config";
|
import { IS_RUNNING_ON_CLOUD } from "./config";
|
||||||
import { PicoBadge } from "./components/PicoBadge";
|
import { PicoBadge } from "./components/PicoBadge";
|
||||||
import { OnboardingNote } from "./components/OnboardingNote";
|
import { OnboardingNote } from "./components/OnboardingNote";
|
||||||
|
import { usePersistedState } from "./hooks/usePersistedState";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [appState, setAppState] = useState<"INITIAL" | "CODING" | "CODE_READY">(
|
const [appState, setAppState] = useState<"INITIAL" | "CODING" | "CODE_READY">(
|
||||||
@ -31,11 +32,11 @@ function App() {
|
|||||||
const [executionConsole, setExecutionConsole] = useState<string[]>([]);
|
const [executionConsole, setExecutionConsole] = useState<string[]>([]);
|
||||||
const [updateInstruction, setUpdateInstruction] = useState("");
|
const [updateInstruction, setUpdateInstruction] = useState("");
|
||||||
const [history, setHistory] = useState<string[]>([]);
|
const [history, setHistory] = useState<string[]>([]);
|
||||||
const [settings, setSettings] = useState<Settings>({
|
const [settings, setSettings] = usePersistedState<Settings>({
|
||||||
openAiApiKey: null,
|
openAiApiKey: null,
|
||||||
isImageGenerationEnabled: true,
|
isImageGenerationEnabled: true,
|
||||||
editorTheme: "cobalt"
|
editorTheme: "cobalt"
|
||||||
});
|
}, 'setting');
|
||||||
|
|
||||||
const downloadCode = () => {
|
const downloadCode = () => {
|
||||||
// Create a blob from the generated code
|
// Create a blob from the generated code
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user