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