persistence db fixes

This commit is contained in:
Kevin Jahns 2017-09-11 16:02:19 +02:00
parent 76ad58bb59
commit fdbb558ce2
2 changed files with 7 additions and 9 deletions

View File

@ -1,11 +1,12 @@
import Y from '../src/y.js' import Y from '../src/y.js'
import yArray from '../../y-array/src/y-array.js' import yArray from '../../y-array/src/y-array.js'
import yIndexedDB from '../../y-indexeddb/src/y-indexeddb.js'
import yMap from '../../y-map/src/y-map.js' import yMap from '../../y-map/src/y-map.js'
import yText from '../../y-text/src/Text.js' import yText from '../../y-text/src/Text.js'
import yXml from '../../y-xml/src/y-xml.js' import yXml from '../../y-xml/src/y-xml.js'
import yWebsocketsClient from '../../y-websockets-client/src/y-websockets-client.js' import yWebsocketsClient from '../../y-websockets-client/src/y-websockets-client.js'
Y.extend(yArray, yMap, yText, yXml, yWebsocketsClient) Y.extend(yArray, yIndexedDB, yMap, yText, yXml, yWebsocketsClient)
export default Y export default Y

View File

@ -150,6 +150,9 @@ export default function Y (opts/* :YOptions */) /* :Promise<YConfig> */ {
} }
}, opts.timeout) }, opts.timeout)
} }
if (yconfig.persistence != null) {
yconfig.persistence.retrieveContent()
}
yconfig.db.whenUserIdSet(function () { yconfig.db.whenUserIdSet(function () {
yconfig.init(function () { yconfig.init(function () {
resolved = true resolved = true
@ -200,15 +203,9 @@ class YConfig extends Y.utils.NamedEventHandler {
share[propertyname] = this.store.initType.call(this, id, args) share[propertyname] = this.store.initType.call(this, id, args)
} }
}) })
if (this.persistence != null) {
this.persistence.retrieveContent()
.then(() => this.db.whenTransactionsFinished())
.then(callback)
} else {
this.db.whenTransactionsFinished() this.db.whenTransactionsFinished()
.then(callback) .then(callback)
} }
}
isConnected () { isConnected () {
return this.connector.isSynced return this.connector.isSynced
} }