Merge branch 'staging' into develop

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-02-06 13:52:19 +07:00
14 changed files with 123 additions and 70 deletions
@@ -97,10 +97,53 @@ export async function OnProjectChanges (txes: Tx[], control: TriggerControl): Pr
return result
}
/**
* @public
*/
export async function OnProjectRemove (txes: Tx[], control: TriggerControl): Promise<Tx[]> {
const result: Tx[] = []
for (const ltx of txes) {
if (ltx._class === core.class.TxRemoveDoc) {
const cud = ltx as TxCUD<Doc>
if (control.hierarchy.isDerived(cud.objectClass, tracker.class.Project)) {
const project = control.removedMap.get(cud.objectId)
if (project === undefined) {
continue
}
if (control.hierarchy.hasMixin(project, github.mixin.GithubProject)) {
const repos = await control.findAll(control.ctx, github.class.GithubIntegrationRepository, {
githubProject: cud.objectId as Ref<GithubProject>
})
for (const repo of repos) {
result.push(
control.txFactory.createTxUpdateDoc(repo._class, repo.space, repo._id, {
enabled: false,
githubProject: null
})
)
}
const syncDocs = control.modelDb.findAllSync(github.class.DocSyncInfo, {
space: cud.objectId as Ref<Space>
})
for (const syncDoc of syncDocs) {
result.push(control.txFactory.createTxRemoveDoc(syncDoc._class, syncDoc.space, syncDoc._id))
}
}
}
}
}
if (result.length > 0) {
await OnGithubBroadcast(txes, control)
}
return result
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export default async () => ({
trigger: {
OnProjectChanges,
OnProjectRemove,
OnGithubBroadcast
},
functions: {