-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
918c5ac
commit 139065b
Showing
9 changed files
with
47 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
import { moduleLogger } from '@/logging/logging' | ||
import { SpeckleModule } from '@/modules/shared/helpers/typeHelper' | ||
import { ENABLE_AUTOMATE_MODULE } from '@/modules/shared/helpers/envHelper' | ||
import { Optional, SpeckleModule } from '@/modules/shared/helpers/typeHelper' | ||
import { VersionEvents, VersionsEmitter } from '@/modules/core/events/versionsEmitter' | ||
import { onModelVersionCreate } from '@/modules/automate/services/trigger' | ||
import { Environment } from '@speckle/shared' | ||
|
||
let quitListeners: Optional<() => void> = undefined | ||
|
||
const { FF_AUTOMATE_MODULE_ENABLED } = Environment.getFeatureFlags() | ||
|
||
const automateModule: SpeckleModule = { | ||
async init() { | ||
if (!ENABLE_AUTOMATE_MODULE) return | ||
async init(_, isInitial) { | ||
if (!FF_AUTOMATE_MODULE_ENABLED) return | ||
moduleLogger.info('⚙️ Init automate module') | ||
|
||
if (isInitial) { | ||
quitListeners = initializeEventListeners() | ||
} | ||
}, | ||
shutdown() { | ||
if (!FF_AUTOMATE_MODULE_ENABLED) return | ||
quitListeners?.() | ||
} | ||
} | ||
|
||
export = automateModule | ||
|
||
const initializeEventListeners = () => { | ||
const quit = VersionsEmitter.listen( | ||
VersionEvents.Created, | ||
async ({ modelId, version }) => { | ||
await onModelVersionCreate({ modelId, versionId: version.id }) | ||
} | ||
) | ||
return quit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters