Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (project) {
// load asset packs
const areLoaded = yield select(hasLoadedAssetPacks)
if (!areLoaded) {
yield put(loadAssetPacksRequest())
}
// fix legacy stuff
let scene: Scene = yield getSceneByProjectId(project.id, type)
yield put(fixLegacyNamespacesRequest(scene))
const fixSuccessAction: FixLegacyNamespacesSuccessAction = yield take(FIX_LEGACY_NAMESPACES_SUCCESS)
scene = fixSuccessAction.payload.scene
// if assets packs are being loaded wait for them to finish
const state: RootState = yield select(state => state)
if (isLoadingType(state.assetPack.loading, LOAD_ASSET_PACKS_REQUEST)) {
yield take(LOAD_ASSET_PACKS_SUCCESS)
}
// sync scene assets
yield put(syncSceneAssetsRequest(scene))
const syncSuccessAction = yield take(SYNC_SCENE_ASSETS_SUCCESS)
scene = syncSuccessAction.payload.scene
yield put(setEditorReadOnly(isReadOnly))
yield createNewEditorScene(project)
// Set the remote url for scripts
yield call(() => editorWindow.editor.sendExternalAction(setScriptUrl(`${BUILDER_SERVER_URL}/storage/assets`)))
// Spawns the assets
yield renderScene(scene)
(projectLoading, authLoading) =>
isLoadingType(authLoading, AUTH_REQUEST) ||
isLoadingType(projectLoading, LOAD_PROJECTS_REQUEST) ||
isLoadingType(projectLoading, LOAD_PUBLIC_PROJECT_REQUEST) ||
isLoadingType(projectLoading, LOAD_POOLS_REQUEST)
)
(projectLoading, authLoading) => isLoadingType(authLoading, AUTH_REQUEST) || isLoadingType(projectLoading, LOAD_PUBLIC_PROJECT_REQUEST)
)
export const isLoggingIn = (state: RootState) => isLoadingType(getLoading(state), AUTH_REQUEST)
export const getIdToken = createSelector(
(project, _ready, loadingProject, loadingAuth) => {
if (project) {
return false
} else if (isLoadingType(loadingProject, LOAD_MANIFEST_REQUEST)) {
return true
} else if (isLoadingType(loadingAuth, AUTH_REQUEST)) {
return true
}
return false
}
)
(projectLoading, authLoading) =>
isLoadingType(authLoading, AUTH_REQUEST) ||
isLoadingType(projectLoading, LOAD_PROJECTS_REQUEST) ||
isLoadingType(projectLoading, LOAD_PUBLIC_PROJECT_REQUEST) ||
isLoadingType(projectLoading, LOAD_POOLS_REQUEST)
)
(project, _ready, loadingProject, loadingAuth) => {
if (project) {
return false
} else if (isLoadingType(loadingProject, LOAD_MANIFEST_REQUEST)) {
return true
} else if (isLoadingType(loadingAuth, AUTH_REQUEST)) {
return true
}
return false
}
)
(projectLoading, authLoading) =>
isLoadingType(authLoading, AUTH_REQUEST) ||
isLoadingType(projectLoading, LOAD_PROJECTS_REQUEST) ||
isLoadingType(projectLoading, LOAD_PUBLIC_PROJECT_REQUEST) ||
isLoadingType(projectLoading, LOAD_POOLS_REQUEST)
)
(projectLoading, authLoading) =>
isLoadingType(authLoading, AUTH_REQUEST) ||
isLoadingType(projectLoading, LOAD_PROJECTS_REQUEST) ||
isLoadingType(projectLoading, LOAD_PUBLIC_PROJECT_REQUEST) ||
isLoadingType(projectLoading, LOAD_POOLS_REQUEST)
)