mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 04:08:19 +00:00
Fix extra proxies (#7483)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
766eb53d10
commit
c496829576
@ -54,9 +54,8 @@ export function clone (obj: any, as?: (doc: any, m: any) => any, needAs?: (value
|
||||
if (type === 'Array') {
|
||||
result[key] = clone(value, as, needAs)
|
||||
} else if (type === 'Object') {
|
||||
const m = needAs?.(value)
|
||||
const valClone = clone(value, as, needAs)
|
||||
result[key] = m !== undefined && as !== undefined ? as(valClone, m) : valClone
|
||||
result[key] = valClone
|
||||
} else if (type === 'Date') {
|
||||
result[key] = new Date(value.getTime())
|
||||
} else {
|
||||
|
@ -18,7 +18,7 @@ import type { AnyAttribute, Class, Classifier, Doc, Domain, Interface, Mixin, Ob
|
||||
import { ClassifierKind } from './classes'
|
||||
import { clone as deepClone } from './clone'
|
||||
import core from './component'
|
||||
import { _createMixinProxy, _mixinClass, _toDoc } from './proxy'
|
||||
import { _createMixinProxy, _mixinClass, _toDoc, PROXY_MIXIN_CLASS_KEY } from './proxy'
|
||||
import type { Tx, TxCreateDoc, TxMixin, TxRemoveDoc, TxUpdateDoc } from './tx'
|
||||
import { TxProcessor } from './tx'
|
||||
|
||||
@ -53,7 +53,9 @@ export class Hierarchy {
|
||||
}
|
||||
|
||||
as<D extends Doc, M extends D>(doc: D, mixin: Ref<Mixin<M>>): M {
|
||||
return new Proxy(doc, this.getMixinProxyHandler(mixin)) as M
|
||||
if ((doc as any)[PROXY_MIXIN_CLASS_KEY] === mixin) return doc as M
|
||||
|
||||
return new Proxy(Hierarchy.toDoc(doc), this.getMixinProxyHandler(mixin)) as M
|
||||
}
|
||||
|
||||
asIf<D extends Doc, M extends D>(doc: D | undefined, mixin: Ref<Mixin<M>>): M | undefined {
|
||||
|
@ -3,7 +3,7 @@ import { Ref } from '.'
|
||||
import type { Doc, Mixin } from './classes'
|
||||
|
||||
const PROXY_TARGET_KEY = '$___proxy_target'
|
||||
const PROXY_MIXIN_CLASS_KEY = '$__mixin'
|
||||
export const PROXY_MIXIN_CLASS_KEY = '$__mixin'
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
Loading…
Reference in New Issue
Block a user