mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-12 19:30:52 +00:00
Fix attached remove (#2661)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
0e6c458bfe
commit
042a8a3f87
@ -356,17 +356,19 @@ export abstract class TxProcessor implements WithTx {
|
||||
static buildDoc2Doc<D extends Doc>(txes: Tx[]): D | undefined {
|
||||
let doc: Doc
|
||||
let createTx = txes.find((tx) => tx._class === core.class.TxCreateDoc)
|
||||
const collectionTxes = false
|
||||
if (createTx === undefined) {
|
||||
const collectionTxes = txes.filter((tx) => tx._class === core.class.TxCollectionCUD) as Array<
|
||||
TxCollectionCUD<Doc, AttachedDoc>
|
||||
>
|
||||
createTx = collectionTxes.find((p) => p.tx._class === core.class.TxCreateDoc)
|
||||
const collectionCreateTx = collectionTxes.find((p) => p.tx._class === core.class.TxCreateDoc)
|
||||
if (collectionCreateTx === undefined) return
|
||||
createTx = TxProcessor.extractTx(collectionCreateTx)
|
||||
}
|
||||
if (createTx === undefined) return
|
||||
const objectId = (createTx as TxCreateDoc<D>).objectId
|
||||
doc = TxProcessor.createDoc2Doc(createTx as TxCreateDoc<Doc>)
|
||||
for (let tx of txes) {
|
||||
if (collectionTxes) {
|
||||
if ((tx as TxCUD<D>).objectId !== objectId && tx._class === core.class.TxCollectionCUD) {
|
||||
tx = TxProcessor.extractTx(tx)
|
||||
}
|
||||
if (tx._class === core.class.TxUpdateDoc) {
|
||||
|
@ -350,8 +350,8 @@ class TServerStorage implements ServerStorage {
|
||||
const removeAttachObjectIds: Ref<AttachedDoc>[] = []
|
||||
|
||||
const removeTxes = rawTxes
|
||||
.filter((it) => this.hierarchy.isDerived(it._class, core.class.TxRemoveDoc))
|
||||
.map((it) => TxProcessor.extractTx(it) as TxRemoveDoc<Doc>)
|
||||
.filter((it) => this.hierarchy.isDerived(it._class, core.class.TxRemoveDoc))
|
||||
|
||||
for (const rtx of removeTxes) {
|
||||
const isAttached = this.hierarchy.isDerived(rtx.objectClass, core.class.AttachedDoc)
|
||||
|
Loading…
Reference in New Issue
Block a user