diff --git a/src/database.ts b/src/database.ts index f6e7595..3e2b948 100644 --- a/src/database.ts +++ b/src/database.ts @@ -348,23 +348,17 @@ export async function createClass(options: CreateClassOptions): Promise { - console.log(setup); - setup(cls, storyName); - }); + const setupFunctions = classSetupRegistry.setupFunctions(storyName); + if (setupFunctions) { + for (const setupFunc of setupFunctions) { + await setupFunc(cls, storyName); + } + } } return cls; }); - // Another piece of Hubble-specific functionality - // Note that we need to reload the class so that the virtual `small_class` - // column has its value populated - await cls.reload(); - if (cls.asynchronous || cls.small_class) { - await addClassToMergeGroup(cls.id); - } - return { result: result, class: creationInfo }; } catch (error) { result = (error instanceof BaseError) ? createClassResultFromError(error) : CreateClassResult.Error; @@ -941,19 +935,3 @@ export async function getDashboardGroupClasses(code: string): Promise void; +type ClassSetupFunction = (cls: Class, storyName: string) => Promise; class ClassSetupRegistry {