Skip to content

Commit

Permalink
[WIP] Fix build after eslint updates
Browse files Browse the repository at this point in the history
  • Loading branch information
saqadri committed Jan 12, 2024
1 parent b8ecba4 commit 20aaf50
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
32 changes: 18 additions & 14 deletions python/src/aiconfig/editor/client/src/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion python/src/aiconfig/editor/client/src/WebviewContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { WebviewApi } from "vscode-webview";
* Context for VSCode Webview state and methods.
*/
const WebviewContext = createContext<{
vscode: WebviewApi<Record<string, any>> | null;
vscode: WebviewApi<Record<string, unknown>> | null;
}>({
vscode: null,
});
Expand Down
3 changes: 1 addition & 2 deletions python/src/aiconfig/editor/client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down

0 comments on commit 20aaf50

Please sign in to comment.