From 20aaf50b5afa45d8360e51e29bc9819c071c1fce Mon Sep 17 00:00:00 2001 From: Sarmad Qadri Date: Fri, 12 Jan 2024 13:57:32 -0500 Subject: [PATCH] [WIP] Fix build after eslint updates --- .../src/aiconfig/editor/client/src/Editor.tsx | 32 +++++++++++-------- .../editor/client/src/WebviewContext.tsx | 2 +- python/src/aiconfig/editor/client/yarn.lock | 3 +- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/python/src/aiconfig/editor/client/src/Editor.tsx b/python/src/aiconfig/editor/client/src/Editor.tsx index 27723ed90..ef1d5dc74 100644 --- a/python/src/aiconfig/editor/client/src/Editor.tsx +++ b/python/src/aiconfig/editor/client/src/Editor.tsx @@ -13,32 +13,36 @@ export default function Editor() { const { vscode } = useContext(WebviewContext); - const updateContent = useCallback(async (text: string) => { - // TODO: saqadri - this won't work for YAML -- the handling of the text needs to include the logic from AIConfig.load - const updatedConfig = text != null ? JSON.parse(text) : {}; - console.log("updatedConfig=", JSON.stringify(updatedConfig)); - setAIConfig(updatedConfig); - - // Then persist state information. - // This state is returned in the call to `vscode.getState` below when a webview is reloaded. - vscode?.setState({ text }); - - // TODO: saqadri - as soon as content is updated, we have to call /load endpoint for the server to have the latest content as well - // However, instead of loading from FS, the /load endpoint should load from the data passed to it here. - }, []); + const updateContent = useCallback( + async (text: string) => { + // TODO: saqadri - this won't work for YAML -- the handling of the text needs to include the logic from AIConfig.load + const updatedConfig = text != null ? JSON.parse(text) : {}; + console.log("updatedConfig=", JSON.stringify(updatedConfig)); + setAIConfig(updatedConfig); + + // Then persist state information. + // This state is returned in the call to `vscode.getState` below when a webview is reloaded. + vscode?.setState({ text }); + + // TODO: saqadri - as soon as content is updated, we have to call /load endpoint for the server to have the latest content as well + // However, instead of loading from FS, the /load endpoint should load from the data passed to it here. + }, + [vscode] + ); // Handle messages sent from the extension to the webview window.addEventListener("message", (event) => { console.log("onMessage, event=", JSON.stringify(event)); const message = event.data; // The json data that the extension sent switch (message.type) { - case "update": + case "update": { console.log("onMessage, message=", JSON.stringify(message)); const text = message.text; // Update our webview's content updateContent(text); return; + } } }); diff --git a/python/src/aiconfig/editor/client/src/WebviewContext.tsx b/python/src/aiconfig/editor/client/src/WebviewContext.tsx index d5672c72e..1484fa8dc 100644 --- a/python/src/aiconfig/editor/client/src/WebviewContext.tsx +++ b/python/src/aiconfig/editor/client/src/WebviewContext.tsx @@ -5,7 +5,7 @@ import { WebviewApi } from "vscode-webview"; * Context for VSCode Webview state and methods. */ const WebviewContext = createContext<{ - vscode: WebviewApi> | null; + vscode: WebviewApi> | null; }>({ vscode: null, }); diff --git a/python/src/aiconfig/editor/client/yarn.lock b/python/src/aiconfig/editor/client/yarn.lock index 4f81f2837..5483990d2 100644 --- a/python/src/aiconfig/editor/client/yarn.lock +++ b/python/src/aiconfig/editor/client/yarn.lock @@ -6339,13 +6339,12 @@ identity-obj-proxy@^3.0.0: dependencies: harmony-reflect "^1.4.6" -ignore@^5.2.0, ignore@^5.2.4: ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.2.0: +ignore@^5.2.0, ignore@^5.2.4: version "5.3.0" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.0.tgz#67418ae40d34d6999c95ff56016759c718c82f78" integrity sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==