mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-07 00:09:34 +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 {
|
static buildDoc2Doc<D extends Doc>(txes: Tx[]): D | undefined {
|
||||||
let doc: Doc
|
let doc: Doc
|
||||||
let createTx = txes.find((tx) => tx._class === core.class.TxCreateDoc)
|
let createTx = txes.find((tx) => tx._class === core.class.TxCreateDoc)
|
||||||
const collectionTxes = false
|
|
||||||
if (createTx === undefined) {
|
if (createTx === undefined) {
|
||||||
const collectionTxes = txes.filter((tx) => tx._class === core.class.TxCollectionCUD) as Array<
|
const collectionTxes = txes.filter((tx) => tx._class === core.class.TxCollectionCUD) as Array<
|
||||||
TxCollectionCUD<Doc, AttachedDoc>
|
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
|
if (createTx === undefined) return
|
||||||
|
const objectId = (createTx as TxCreateDoc<D>).objectId
|
||||||
doc = TxProcessor.createDoc2Doc(createTx as TxCreateDoc<Doc>)
|
doc = TxProcessor.createDoc2Doc(createTx as TxCreateDoc<Doc>)
|
||||||
for (let tx of txes) {
|
for (let tx of txes) {
|
||||||
if (collectionTxes) {
|
if ((tx as TxCUD<D>).objectId !== objectId && tx._class === core.class.TxCollectionCUD) {
|
||||||
tx = TxProcessor.extractTx(tx)
|
tx = TxProcessor.extractTx(tx)
|
||||||
}
|
}
|
||||||
if (tx._class === core.class.TxUpdateDoc) {
|
if (tx._class === core.class.TxUpdateDoc) {
|
||||||
|
@ -350,8 +350,8 @@ class TServerStorage implements ServerStorage {
|
|||||||
const removeAttachObjectIds: Ref<AttachedDoc>[] = []
|
const removeAttachObjectIds: Ref<AttachedDoc>[] = []
|
||||||
|
|
||||||
const removeTxes = rawTxes
|
const removeTxes = rawTxes
|
||||||
.filter((it) => this.hierarchy.isDerived(it._class, core.class.TxRemoveDoc))
|
|
||||||
.map((it) => TxProcessor.extractTx(it) as TxRemoveDoc<Doc>)
|
.map((it) => TxProcessor.extractTx(it) as TxRemoveDoc<Doc>)
|
||||||
|
.filter((it) => this.hierarchy.isDerived(it._class, core.class.TxRemoveDoc))
|
||||||
|
|
||||||
for (const rtx of removeTxes) {
|
for (const rtx of removeTxes) {
|
||||||
const isAttached = this.hierarchy.isDerived(rtx.objectClass, core.class.AttachedDoc)
|
const isAttached = this.hierarchy.isDerived(rtx.objectClass, core.class.AttachedDoc)
|
||||||
|
Loading…
Reference in New Issue
Block a user