fix: load data on first time

This commit is contained in:
DarkSky
2022-08-11 10:44:22 +08:00
parent 86090be4a3
commit e9447cdcfe

View File

@@ -163,8 +163,8 @@ export class SQLiteProvider extends Observable<string> {
} }
} }
private _waitUpdate(sync = false) { private _waitUpdate(updates: any[], sync = false) {
if (sync) { if (updates.length && sync) {
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
const final = (_: any, origin: any) => { const final = (_: any, origin: any) => {
if (origin === this) { if (origin === this) {
@@ -180,8 +180,8 @@ export class SQLiteProvider extends Observable<string> {
private async _fetchUpdates(sync = false) { private async _fetchUpdates(sync = false) {
if (this.db) { if (this.db) {
const wait = this._waitUpdate(sync);
const updates = getAllUpdates(this.db, this._ref); const updates = getAllUpdates(this.db, this._ref);
const wait = this._waitUpdate(updates, sync);
Y.transact( Y.transact(
this.doc, this.doc,