Fixing issue with apps not being created correctly due to the recent update to context.
This commit is contained in:
parent
4ed239e5fd
commit
6e3f87c798
|
@ -112,11 +112,11 @@ function checkAppName(
|
|||
}
|
||||
}
|
||||
|
||||
async function createInstance(template: any, includeSampleData: boolean) {
|
||||
const tenantId = tenancy.isMultiTenant() ? tenancy.getTenantId() : null
|
||||
const baseAppId = generateAppID(tenantId)
|
||||
const appId = generateDevAppID(baseAppId)
|
||||
return await context.doInAppContext(appId, async () => {
|
||||
async function createInstance(
|
||||
appId: string,
|
||||
template: any,
|
||||
includeSampleData: boolean
|
||||
) {
|
||||
const db = context.getAppDB()
|
||||
await db.put({
|
||||
_id: "_design/database",
|
||||
|
@ -151,7 +151,6 @@ async function createInstance(template: any, includeSampleData: boolean) {
|
|||
}
|
||||
|
||||
return { _id: appId }
|
||||
})
|
||||
}
|
||||
|
||||
async function addDefaultTables(db: Database) {
|
||||
|
@ -250,8 +249,15 @@ async function performAppCreate(ctx: BBContext) {
|
|||
instanceConfig.file = ctx.request.files.templateFile
|
||||
}
|
||||
const includeSampleData = isQsTrue(ctx.request.body.sampleData)
|
||||
const instance = await createInstance(instanceConfig, includeSampleData)
|
||||
const appId = instance._id
|
||||
const tenantId = tenancy.isMultiTenant() ? tenancy.getTenantId() : null
|
||||
const appId = generateDevAppID(generateAppID(tenantId))
|
||||
|
||||
return await context.doInAppContext(appId, async () => {
|
||||
const instance = await createInstance(
|
||||
appId,
|
||||
instanceConfig,
|
||||
includeSampleData
|
||||
)
|
||||
const db = context.getAppDB()
|
||||
|
||||
let newApplication: App = {
|
||||
|
@ -326,6 +332,7 @@ async function performAppCreate(ctx: BBContext) {
|
|||
|
||||
await cache.app.invalidateAppMetadata(appId, newApplication)
|
||||
return newApplication
|
||||
})
|
||||
}
|
||||
|
||||
async function creationEvents(request: any, app: App) {
|
||||
|
|
Loading…
Reference in New Issue