unbork onPut
This commit is contained in:
parent
24e14e41a2
commit
264518a5c4
|
@ -197,30 +197,20 @@ const syncMan = (() => {
|
||||||
},
|
},
|
||||||
async onPut(doc) {
|
async onPut(doc) {
|
||||||
const id = uuidIndex.get(doc._id);
|
const id = uuidIndex.get(doc._id);
|
||||||
const style = styleUtil.id2style(id);
|
const oldCust = customDocs[id];
|
||||||
const oldDoc = style || customDocs[id];
|
const oldDoc = oldCust || styleUtil.id2style(id);
|
||||||
if (id) {
|
const diff = oldDoc ? compareRevision(oldDoc._rev, doc._rev) : -1;
|
||||||
doc.id = id;
|
if (!diff) return;
|
||||||
|
if (diff > 0) {
|
||||||
|
syncMan.putDoc(oldDoc);
|
||||||
|
} else if (oldCust) {
|
||||||
|
customDocs[id] = doc;
|
||||||
} else {
|
} else {
|
||||||
delete doc.id;
|
delete doc.id;
|
||||||
}
|
if (id) doc.id = id;
|
||||||
let diff = -1;
|
|
||||||
if (oldDoc) {
|
|
||||||
diff = compareRevision(oldDoc._rev, doc._rev);
|
|
||||||
if (diff > 0) {
|
|
||||||
syncMan.putDoc(oldDoc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (diff >= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (style) {
|
|
||||||
doc.id = await db.styles.put(doc);
|
doc.id = await db.styles.put(doc);
|
||||||
uuidIndex.set(doc._id, doc.id);
|
|
||||||
return styleUtil.handleSave(doc, {reason: 'sync'});
|
return styleUtil.handleSave(doc, {reason: 'sync'});
|
||||||
}
|
}
|
||||||
if (oldDoc) customDocs[id] = doc;
|
|
||||||
},
|
},
|
||||||
onDelete(_id, rev) {
|
onDelete(_id, rev) {
|
||||||
const id = uuidIndex.get(_id);
|
const id = uuidIndex.get(_id);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user