Move load status to init

This commit is contained in:
haad 2016-03-22 17:59:55 +01:00
parent 76a0ad5d52
commit 0509b6ee5d

View File

@ -22,13 +22,13 @@ class OrbitDB {
this._logs[channel] = await(Log.create(this._ipfs, this.user.username)); this._logs[channel] = await(Log.create(this._ipfs, this.user.username));
this.events[channel] = new EventEmitter(); this.events[channel] = new EventEmitter();
this.events[channel].emit('load', channel);
Cache.loadCache(); Cache.loadCache();
this.sync(channel, Cache.get(channel)); this.sync(channel, Cache.get(channel));
this.events[channel].emit('loaded', channel);
} }
sync(channel, hash) { sync(channel, hash) {
this.events[channel].emit('load', channel, hash);
// setTimeout(async(() => {
// console.log("--> Head:", hash) // console.log("--> Head:", hash)
if(hash && this._logs[channel]) { if(hash && this._logs[channel]) {
const oldCount = this._logs[channel].items.length; const oldCount = this._logs[channel].items.length;
@ -42,8 +42,6 @@ class OrbitDB {
Cache.set(channel, hash); Cache.set(channel, hash);
} }
} }
this.events[channel].emit('loaded', channel, hash);
// }), 3000);
} }
/* DB Operations */ /* DB Operations */