- Now conflict resolution back well
This commit is contained in:
vorotamoroz
2022-07-29 09:38:23 +09:00
parent 61b65b0461
commit 05b53eb2cf
2 changed files with 21 additions and 3 deletions

View File

@@ -146,6 +146,17 @@ export class DocumentHistoryModal extends Modal {
Logger(`Old content copied to clipboard`, LOG_LEVEL.NOTICE);
});
});
async function focusFile(path: string) {
const targetFile = app.vault
.getFiles()
.find((f) => f.path === path);
if (targetFile) {
const leaf = app.workspace.getLeaf(false);
await leaf.openFile(targetFile);
} else {
Logger("The file cound not view on the editor", LOG_LEVEL.NOTICE)
}
}
buttons.createEl("button", { text: "Back to this revision" }, (e) => {
e.addClass("mod-cta");
e.addEventListener("click", async () => {
@@ -155,9 +166,11 @@ export class DocumentHistoryModal extends Modal {
}
if (this.currentDoc?.datatype == "plain") {
await this.app.vault.adapter.write(pathToWrite, this.currentDoc.data);
await focusFile(pathToWrite);
this.close();
} else if (this.currentDoc?.datatype == "newnote") {
await this.app.vault.adapter.writeBinary(pathToWrite, base64ToArrayBuffer(this.currentDoc.data));
await focusFile(pathToWrite);
this.close();
} else {

View File

@@ -462,6 +462,7 @@ export class LocalPouchDB {
} else {
obj = await this.localDatabase.get(id);
}
const revDeletion = ("rev" in opt ? opt.rev : "") != "";
if (obj.type && obj.type == "leaf") {
//do nothing for leaf;
@@ -479,11 +480,15 @@ export class LocalPouchDB {
// simple note
}
if (obj.type == "newnote" || obj.type == "plain") {
obj.deleted = true;
if (this.settings.deleteMetadataOfDeletedFiles) {
if (revDeletion) {
obj._deleted = true;
} else {
obj.deleted = true;
obj.mtime = Date.now();
if (this.settings.deleteMetadataOfDeletedFiles) {
obj._deleted = true;
}
}
obj.mtime = Date.now();
const r = await this.localDatabase.put(obj);
Logger(`entry removed:${obj._id}-${r.rev}`);
if (typeof this.corruptedEntries[obj._id] != "undefined") {