Spaces:
Runtime error
Runtime error
fix: better delete mode
Browse files- src/pages/index.tsx +10 -27
- src/services/api/index.ts +1 -0
src/pages/index.tsx
CHANGED
@@ -35,11 +35,11 @@ import { useHost } from "esdeka/react";
|
|
35 |
import CircularProgress from "@mui/material/CircularProgress";
|
36 |
import CssBaseline from "@mui/material/CssBaseline";
|
37 |
import Slider from "@mui/material/Slider";
|
38 |
-
// import dynamic from "next/dynamic";
|
39 |
-
// const MonacoEditor = dynamic(import("@monaco-editor/react"), { ssr: false });
|
40 |
|
41 |
const base = {
|
42 |
-
default:
|
|
|
|
|
43 |
const canvas = document.querySelector('canvas');
|
44 |
const ctx = canvas.getContext('2d');
|
45 |
/*60FPS draw cycle*/
|
@@ -123,26 +123,6 @@ export default function Home() {
|
|
123 |
};
|
124 |
}, [subscribe, loadingLive]);
|
125 |
|
126 |
-
// Broadcast store to guest
|
127 |
-
// useEffect(() => {
|
128 |
-
// const current = answers.find(({ id }) => id === runningId);
|
129 |
-
// if (connection.current && current) {
|
130 |
-
// broadcast({ template: current.content });
|
131 |
-
// }
|
132 |
-
// return () => {
|
133 |
-
// /* Consistency */
|
134 |
-
// };
|
135 |
-
// }, [broadcast, runningId, answers]);
|
136 |
-
|
137 |
-
// useEffect(() => {
|
138 |
-
// const current = answers.find(({ id }) => id === runningId);
|
139 |
-
// if (current) {
|
140 |
-
// void axios.post("/api/run", {
|
141 |
-
// content: current.content,
|
142 |
-
// });
|
143 |
-
// }
|
144 |
-
// }, [runningId, answers]);
|
145 |
-
|
146 |
const current = answers.find(({ id }) => id === activeId);
|
147 |
|
148 |
function reload() {
|
@@ -179,7 +159,7 @@ export default function Home() {
|
|
179 |
setLoading(true);
|
180 |
const { data } = await axios.post("/api/gpt", formObject);
|
181 |
const answer = data;
|
182 |
-
setAnswers([answer, ...
|
183 |
setRunningId(answer.id);
|
184 |
reload();
|
185 |
} catch (error) {
|
@@ -287,7 +267,7 @@ export default function Home() {
|
|
287 |
name="template"
|
288 |
label="Template"
|
289 |
placeholder={base.default}
|
290 |
-
maxRows={
|
291 |
value={template}
|
292 |
InputProps={{
|
293 |
style: { ...fontMono.style },
|
@@ -312,11 +292,14 @@ export default function Home() {
|
|
312 |
edge="end"
|
313 |
aria-label="Delete"
|
314 |
onClick={() => {
|
315 |
-
setAnswers(
|
316 |
-
|
317 |
({ id }) => id !== answer.id
|
318 |
)
|
319 |
);
|
|
|
|
|
|
|
320 |
}}
|
321 |
>
|
322 |
<DeleteForeverIcon />
|
|
|
35 |
import CircularProgress from "@mui/material/CircularProgress";
|
36 |
import CssBaseline from "@mui/material/CssBaseline";
|
37 |
import Slider from "@mui/material/Slider";
|
|
|
|
|
38 |
|
39 |
const base = {
|
40 |
+
default: `/** CHANGELOG
|
41 |
+
* 1. Set up canvas
|
42 |
+
*/
|
43 |
const canvas = document.querySelector('canvas');
|
44 |
const ctx = canvas.getContext('2d');
|
45 |
/*60FPS draw cycle*/
|
|
|
123 |
};
|
124 |
}, [subscribe, loadingLive]);
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
const current = answers.find(({ id }) => id === activeId);
|
127 |
|
128 |
function reload() {
|
|
|
159 |
setLoading(true);
|
160 |
const { data } = await axios.post("/api/gpt", formObject);
|
161 |
const answer = data;
|
162 |
+
setAnswers(previousAnswers => [answer, ...previousAnswers]);
|
163 |
setRunningId(answer.id);
|
164 |
reload();
|
165 |
} catch (error) {
|
|
|
267 |
name="template"
|
268 |
label="Template"
|
269 |
placeholder={base.default}
|
270 |
+
maxRows={10}
|
271 |
value={template}
|
272 |
InputProps={{
|
273 |
style: { ...fontMono.style },
|
|
|
292 |
edge="end"
|
293 |
aria-label="Delete"
|
294 |
onClick={() => {
|
295 |
+
setAnswers(previousAnswers =>
|
296 |
+
previousAnswers.filter(
|
297 |
({ id }) => id !== answer.id
|
298 |
)
|
299 |
);
|
300 |
+
setRunningId("1");
|
301 |
+
setTemplate(base.default);
|
302 |
+
reload();
|
303 |
}}
|
304 |
>
|
305 |
<DeleteForeverIcon />
|
src/services/api/index.ts
CHANGED
@@ -57,6 +57,7 @@ export async function toOpenAI({
|
|
57 |
All UPPERCASE words are IMPORTANT, all "UPPERCASE" words in QUOTES (") indicate KEYWORDS.
|
58 |
You are: expert JavaScript Developer, creative, Canvas-2d expert, performance guru, interaction expert.
|
59 |
You strictly follow all "DOCS".
|
|
|
60 |
You ALWAYS follow the "ADD", "REMOVE", "INPUT" and "OUTPUT FORMAT".
|
61 |
You NEVER explain anything.
|
62 |
|
|
|
57 |
All UPPERCASE words are IMPORTANT, all "UPPERCASE" words in QUOTES (") indicate KEYWORDS.
|
58 |
You are: expert JavaScript Developer, creative, Canvas-2d expert, performance guru, interaction expert.
|
59 |
You strictly follow all "DOCS".
|
60 |
+
You extend "CHANGELOG".
|
61 |
You ALWAYS follow the "ADD", "REMOVE", "INPUT" and "OUTPUT FORMAT".
|
62 |
You NEVER explain anything.
|
63 |
|