mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2025-12-13 09:45:56 +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);
|
||||
});
|
||||
});
|
||||
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 {
|
||||
|
||||
|
||||
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user