add option to disable gc (compatible with older versions)
This commit is contained in:
parent
bc32f7348e
commit
bdb3782f8f
@ -25,7 +25,7 @@ function _integrateRemoteStructHelper (y, struct) {
|
|||||||
if (y.ss.getState(id.user) > id.clock) {
|
if (y.ss.getState(id.user) > id.clock) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (struct.constructor === GC || (struct._parent.constructor !== GC && struct._parent._deleted === false)) {
|
if (!y.gcEnabled || struct.constructor === GC || (struct._parent.constructor !== GC && struct._parent._deleted === false)) {
|
||||||
// Is either a GC or Item with an undeleted parent
|
// Is either a GC or Item with an undeleted parent
|
||||||
// save to integrate
|
// save to integrate
|
||||||
struct._integrate(y)
|
struct._integrate(y)
|
||||||
|
@ -217,8 +217,8 @@ export default class Type extends Item {
|
|||||||
* collect the children of this type.
|
* collect the children of this type.
|
||||||
*/
|
*/
|
||||||
_delete (y, createDelete, gcChildren) {
|
_delete (y, createDelete, gcChildren) {
|
||||||
if (gcChildren === undefined) {
|
if (gcChildren === undefined || !y.gcEnabled) {
|
||||||
gcChildren = y._hasUndoManager === false
|
gcChildren = y._hasUndoManager === false && y.gcEnabled
|
||||||
}
|
}
|
||||||
super._delete(y, createDelete, gcChildren)
|
super._delete(y, createDelete, gcChildren)
|
||||||
y._transaction.changedTypes.delete(this)
|
y._transaction.changedTypes.delete(this)
|
||||||
|
3
src/Y.js
3
src/Y.js
@ -28,8 +28,9 @@ export { default as DomBinding } from './Bindings/DomBinding/DomBinding.js'
|
|||||||
* @param {AbstractPersistence} persistence Persistence adapter instance
|
* @param {AbstractPersistence} persistence Persistence adapter instance
|
||||||
*/
|
*/
|
||||||
export default class Y extends NamedEventHandler {
|
export default class Y extends NamedEventHandler {
|
||||||
constructor (room, opts, persistence) {
|
constructor (room, opts, persistence, conf = {}) {
|
||||||
super()
|
super()
|
||||||
|
this.gcEnabled = conf.gc || false
|
||||||
/**
|
/**
|
||||||
* The room name that this Yjs instance connects to.
|
* The room name that this Yjs instance connects to.
|
||||||
* @type {String}
|
* @type {String}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user