Skip to content

Commit c6943bc

Browse files
refactor: WSEditor to async/await pattern
1 parent 980f819 commit c6943bc

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/web/src/views/workspace/components/WSEditor/WSEditor.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import WSEditorCommandGroupContent from "../WSEditorCommandGroupContent";
99
import WSEditorCommandContent from "../WSEditorCommandContent";
1010
import WSEditorClientConfigDialog from "./WSEditorClientConfig";
1111
import type { CommandGroup, Command } from "../../interfaces";
12-
import type { ClientConfig } from "../../../../services";
1312
import WSEditorExportDialog from "./WSEditorExportDialog";
1413
import WSEditorDeleteDialog from "./WSEditorDeleteDialog";
1514
import WSEditorSwaggerReloadDialog from "./WSEditorSwaggerReloadDialog";
@@ -45,16 +44,20 @@ function WSEditor({ params }: WSEditorProps) {
4544
useEffect(() => {
4645
if (!workspace.reloadTimestamp) return;
4746

48-
if (workspace.clientConfigurable) {
49-
workspace
50-
.getWorkspaceClientConfig(workspace.workspaceUrl)
51-
.then((clientConfig: ClientConfig | null) => {
47+
const checkClientConfig = async () => {
48+
if (workspace.clientConfigurable) {
49+
try {
50+
const clientConfig = await workspace.getWorkspaceClientConfig(workspace.workspaceUrl);
5251
if (!clientConfig) {
5352
dialogManager.openClientConfigDialog();
5453
}
55-
})
56-
.catch(console.error);
57-
}
54+
} catch (error) {
55+
console.error(error);
56+
}
57+
}
58+
};
59+
60+
checkClientConfig();
5861

5962
if (workspace.commandTree.length === 0) {
6063
dialogManager.openSwaggerResourcePicker();

src/web/src/views/workspace/components/WSEditorCommandContent/WSEditorCommandContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ const WSEditorCommandContent: React.FC<WSEditorCommandContentProps> = ({
101101

102102
useEffect(() => {
103103
const loadCommand = async () => {
104-
const requestKey = `${previewCommand.id}-${reloadTimestamp}`;
104+
const requestKey = `${workspaceUrl}-${previewCommand.id}-${reloadTimestamp}`;
105105

106-
if (lastLoadRef.current === requestKey || loading) {
106+
if (lastLoadRef.current === requestKey) {
107107
return;
108108
}
109109

0 commit comments

Comments
 (0)