mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2025-12-24 07:01:29 +00:00
Fixes:
- Now conflict resolution back well
This commit is contained in:
@@ -146,6 +146,17 @@ export class DocumentHistoryModal extends Modal {
|
|||||||
Logger(`Old content copied to clipboard`, LOG_LEVEL.NOTICE);
|
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) => {
|
buttons.createEl("button", { text: "Back to this revision" }, (e) => {
|
||||||
e.addClass("mod-cta");
|
e.addClass("mod-cta");
|
||||||
e.addEventListener("click", async () => {
|
e.addEventListener("click", async () => {
|
||||||
@@ -155,9 +166,11 @@ export class DocumentHistoryModal extends Modal {
|
|||||||
}
|
}
|
||||||
if (this.currentDoc?.datatype == "plain") {
|
if (this.currentDoc?.datatype == "plain") {
|
||||||
await this.app.vault.adapter.write(pathToWrite, this.currentDoc.data);
|
await this.app.vault.adapter.write(pathToWrite, this.currentDoc.data);
|
||||||
|
await focusFile(pathToWrite);
|
||||||
this.close();
|
this.close();
|
||||||
} else if (this.currentDoc?.datatype == "newnote") {
|
} else if (this.currentDoc?.datatype == "newnote") {
|
||||||
await this.app.vault.adapter.writeBinary(pathToWrite, base64ToArrayBuffer(this.currentDoc.data));
|
await this.app.vault.adapter.writeBinary(pathToWrite, base64ToArrayBuffer(this.currentDoc.data));
|
||||||
|
await focusFile(pathToWrite);
|
||||||
this.close();
|
this.close();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@@ -462,6 +462,7 @@ export class LocalPouchDB {
|
|||||||
} else {
|
} else {
|
||||||
obj = await this.localDatabase.get(id);
|
obj = await this.localDatabase.get(id);
|
||||||
}
|
}
|
||||||
|
const revDeletion = ("rev" in opt ? opt.rev : "") != "";
|
||||||
|
|
||||||
if (obj.type && obj.type == "leaf") {
|
if (obj.type && obj.type == "leaf") {
|
||||||
//do nothing for leaf;
|
//do nothing for leaf;
|
||||||
@@ -479,11 +480,15 @@ export class LocalPouchDB {
|
|||||||
// simple note
|
// simple note
|
||||||
}
|
}
|
||||||
if (obj.type == "newnote" || obj.type == "plain") {
|
if (obj.type == "newnote" || obj.type == "plain") {
|
||||||
obj.deleted = true;
|
if (revDeletion) {
|
||||||
if (this.settings.deleteMetadataOfDeletedFiles) {
|
|
||||||
obj._deleted = true;
|
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);
|
const r = await this.localDatabase.put(obj);
|
||||||
Logger(`entry removed:${obj._id}-${r.rev}`);
|
Logger(`entry removed:${obj._id}-${r.rev}`);
|
||||||
if (typeof this.corruptedEntries[obj._id] != "undefined") {
|
if (typeof this.corruptedEntries[obj._id] != "undefined") {
|
||||||
|
|||||||
Reference in New Issue
Block a user