Skip to content

Commit

Permalink
explainTypes called in a non blocking way
Browse files Browse the repository at this point in the history
  • Loading branch information
anasilva105 committed Sep 4, 2024
1 parent 244f6d9 commit 0c92163
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/config/metadatatypes.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const metadatatypes = [
import SupportedMetadataTypes from "../shared/interfaces/supportedMetadataTypes";

export const metadatatypes: SupportedMetadataTypes[] = [
{
name: "Asset-[Subtype]",
apiName: "asset",
Expand Down
1 change: 0 additions & 1 deletion src/devtools/commands/DevToolsAdminCommands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import DevToolsCommands from "./DevToolsCommands";
import DevToolsCommandSetting from "../../shared/interfaces/devToolsCommandSetting";
import DevToolsCommandRunner from "../../shared/interfaces/devToolsCommandRunner";
import SupportedMetadataTypes from "../../shared/interfaces/supportedMetadataTypes";
import { log } from "../../editor/output";

class DevToolsAdminCommands extends DevToolsCommands {
Expand Down
20 changes: 16 additions & 4 deletions src/devtools/commands/DevToolsCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,23 @@ abstract class DevToolsCommands {
}, {});
}

// Sets the metadata types sorted by name
const sortedSuppMdtByName: SupportedMetadataTypes[] = metadatatypes.sort((a, b) =>
a.name.localeCompare(b.name)
// sets default metadata type file
this.setMetadataTypes(metadatatypes);

// Updates metadatypes with the result from explainTypes command, not blocking code execution
this.runCommand(
"admin",
"etypes",
"",
{ json: true },
{
handleCommandResult: ({ success, data }: { success: boolean; data: string }) => {
if (success) {
this.setMetadataTypes(JSON.parse(data) as SupportedMetadataTypes[]);
}
}
}
);
this.setMetadataTypes(sortedSuppMdtByName);
}

static async runCommand(
Expand Down

0 comments on commit 0c92163

Please sign in to comment.