Added Metadata sync for friendly name
This commit is contained in:
parent
4db349581b
commit
f479f6043f
@ -94,6 +94,26 @@ export class PouchdbPersistenceManager {
|
|||||||
await this.sendLocalDataToScene();
|
await this.sendLocalDataToScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async setupMetadata(current: string) {
|
||||||
|
try {
|
||||||
|
const doc = await this.db.get('metadata');
|
||||||
|
if (doc && doc.friendly) {
|
||||||
|
localStorage.setItem(current, doc.friendly);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (err.status == 404) {
|
||||||
|
console.log('no metadata found');
|
||||||
|
const friendly = localStorage.getItem(current);
|
||||||
|
if (friendly) {
|
||||||
|
console.log('local friendly name found ', friendly, ' setting metadata');
|
||||||
|
const newDoc = {_id: 'metadata', friendly: friendly};
|
||||||
|
await this.db.put(newDoc);
|
||||||
|
} else {
|
||||||
|
console.log('no friendly name found');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private async initLocal(): Promise<boolean> {
|
private async initLocal(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
let sync = false;
|
let sync = false;
|
||||||
@ -103,8 +123,10 @@ export class PouchdbPersistenceManager {
|
|||||||
} else {
|
} else {
|
||||||
current = 'localdb';
|
current = 'localdb';
|
||||||
}
|
}
|
||||||
this.db = new PouchDB(current);
|
this.db = new PouchDB(current, {auto_compaction: true});
|
||||||
|
await this.db.compact();
|
||||||
if (sync) {
|
if (sync) {
|
||||||
|
await this.setupMetadata(current);
|
||||||
await this.beginSync(current);
|
await this.beginSync(current);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user