From 79e36c95296406b5fd3225901c6f6c119fb8b4d3 Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Wed, 6 Dec 2023 19:07:22 -0500 Subject: [PATCH] move files around --- frontend/src/App.tsx | 5 ++-- .../{ => history}/HistoryDisplay.tsx | 25 +------------------ frontend/src/components/history/utils.ts | 24 ++++++++++++++++++ 3 files changed, 27 insertions(+), 27 deletions(-) rename frontend/src/components/{ => history}/HistoryDisplay.tsx (72%) create mode 100644 frontend/src/components/history/utils.ts diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index fc5521a..22ec502 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -30,9 +30,8 @@ import { USER_CLOSE_WEB_SOCKET_CODE } from "./constants"; import CodeTab from "./components/CodeTab"; import OutputSettingsSection from "./components/OutputSettingsSection"; import { History } from "./history_types"; -import HistoryDisplay, { - extractHistoryTree, -} from "./components/HistoryDisplay"; +import HistoryDisplay from "./components/history/HistoryDisplay"; +import { extractHistoryTree } from "./components/history/utils"; import toast from "react-hot-toast"; const IS_OPENAI_DOWN = false; diff --git a/frontend/src/components/HistoryDisplay.tsx b/frontend/src/components/history/HistoryDisplay.tsx similarity index 72% rename from frontend/src/components/HistoryDisplay.tsx rename to frontend/src/components/history/HistoryDisplay.tsx index 69eb025..b626df4 100644 --- a/frontend/src/components/HistoryDisplay.tsx +++ b/frontend/src/components/history/HistoryDisplay.tsx @@ -1,5 +1,5 @@ import { ScrollArea } from "@/components/ui/scroll-area"; -import { History, HistoryItemType } from "../history_types"; +import { History, HistoryItemType } from "../../history_types"; import toast from "react-hot-toast"; import classNames from "classnames"; @@ -10,29 +10,6 @@ interface Props { shouldDisableReverts: boolean; } -export function extractHistoryTree( - history: History, - version: number -): string[] { - // History is in reverse chronological order - - // Get all history items up to the current version - const extractedHistory = history.slice(version); - - const obj: string[] = []; - - // Reverse the history so that it is in chronological order for the server - extractedHistory.reverse().forEach((item) => { - // Don't include the image for ai_create since the server gets it passed and will include it directly - if (item.type !== "ai_create") { - obj.push(item.inputs.prompt); - } - obj.push(item.code); - }); - - return obj; -} - function displayHistoryItemType(itemType: HistoryItemType) { switch (itemType) { case "ai_create": diff --git a/frontend/src/components/history/utils.ts b/frontend/src/components/history/utils.ts new file mode 100644 index 0000000..8c7065f --- /dev/null +++ b/frontend/src/components/history/utils.ts @@ -0,0 +1,24 @@ +import { History } from "../../history_types"; + +export function extractHistoryTree( + history: History, + version: number +): string[] { + // History is in reverse chronological order + + // Get all history items up to the current version + const extractedHistory = history.slice(version); + + const obj: string[] = []; + + // Reverse the history so that it is in chronological order for the server + extractedHistory.reverse().forEach((item) => { + // Don't include the image for ai_create since the server gets it passed and will include it directly + if (item.type !== "ai_create") { + obj.push(item.inputs.prompt); + } + obj.push(item.code); + }); + + return obj; +}