mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-11 11:52:31 +00:00
Fixed:
- Conflict merge of internal files is no longer broken. Improved: - Smoother status display inside the editor.
This commit is contained in:
+28
-24
@@ -1722,10 +1722,14 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
|
|
||||||
if (this.settings.showStatusOnEditor) {
|
if (this.settings.showStatusOnEditor) {
|
||||||
const root = activeDocument.documentElement;
|
const root = activeDocument.documentElement;
|
||||||
root.style.setProperty("--slsmessage", '"' + (newMsg + "\n" + newLog).split("\n").join("\\a ") + '"');
|
const q = root.querySelectorAll(`.CodeMirror-wrap,.cm-s-obsidian>.cm-editor,.canvas-wrapper`);
|
||||||
|
q.forEach(e => e.setAttr("data-log", '' + (newMsg + "\n" + newLog) + ''))
|
||||||
|
// root.style.setProperty("--slsmessage", '"' + (newMsg + "\n" + newLog).split("\n").join("\\a ") + '"');
|
||||||
} else {
|
} else {
|
||||||
const root = activeDocument.documentElement;
|
const root = activeDocument.documentElement;
|
||||||
root.style.setProperty("--slsmessage", '""');
|
// root.style.setProperty("--slsmessage", '""');
|
||||||
|
const q = root.querySelectorAll(`.CodeMirror-wrap,.cm-s-obsidian>.cm-editor,.canvas-wrapper`);
|
||||||
|
q.forEach(e => e.setAttr("data-log", ''))
|
||||||
}
|
}
|
||||||
if (this.logHideTimer != null) {
|
if (this.logHideTimer != null) {
|
||||||
clearTimeout(this.logHideTimer);
|
clearTimeout(this.logHideTimer);
|
||||||
@@ -2973,33 +2977,33 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
if (doc._conflicts.length == 0) return false;
|
if (doc._conflicts.length == 0) return false;
|
||||||
Logger(`Hidden file conflicted:${id2filenameInternalChunk(id)}`);
|
Logger(`Hidden file conflicted:${id2filenameInternalChunk(id)}`);
|
||||||
const conflicts = doc._conflicts.sort((a, b) => Number(a.split("-")[0]) - Number(b.split("-")[0]));
|
const conflicts = doc._conflicts.sort((a, b) => Number(a.split("-")[0]) - Number(b.split("-")[0]));
|
||||||
|
|
||||||
const revA = doc._rev;
|
const revA = doc._rev;
|
||||||
const revB = conflicts[0];
|
const revB = conflicts[0];
|
||||||
|
|
||||||
const conflictedRev = conflicts[0];
|
if (doc._id.endsWith(".json")) {
|
||||||
const conflictedRevNo = Number(conflictedRev.split("-")[0]);
|
const conflictedRev = conflicts[0];
|
||||||
//Search
|
const conflictedRevNo = Number(conflictedRev.split("-")[0]);
|
||||||
const revFrom = (await this.localDatabase.localDatabase.get(id, { revs_info: true })) as unknown as LoadedEntry & PouchDB.Core.GetMeta;
|
//Search
|
||||||
const commonBase = revFrom._revs_info.filter(e => e.status == "available" && Number(e.rev.split("-")[0]) < conflictedRevNo).first()?.rev ?? "";
|
const revFrom = (await this.localDatabase.localDatabase.get(id, { revs_info: true })) as unknown as LoadedEntry & PouchDB.Core.GetMeta;
|
||||||
const result = await this.mergeObject(id, commonBase, doc._rev, conflictedRev);
|
const commonBase = revFrom._revs_info.filter(e => e.status == "available" && Number(e.rev.split("-")[0]) < conflictedRevNo).first()?.rev ?? "";
|
||||||
if (result) {
|
const result = await this.mergeObject(id, commonBase, doc._rev, conflictedRev);
|
||||||
Logger(`Object merge:${id}`, LOG_LEVEL.INFO);
|
if (result) {
|
||||||
const filename = id2filenameInternalChunk(id);
|
Logger(`Object merge:${id}`, LOG_LEVEL.INFO);
|
||||||
const isExists = await this.app.vault.adapter.exists(filename);
|
const filename = id2filenameInternalChunk(id);
|
||||||
if (!isExists) {
|
const isExists = await this.app.vault.adapter.exists(filename);
|
||||||
await this.ensureDirectoryEx(filename);
|
if (!isExists) {
|
||||||
|
await this.ensureDirectoryEx(filename);
|
||||||
|
}
|
||||||
|
await this.app.vault.adapter.write(filename, result);
|
||||||
|
const stat = await this.app.vault.adapter.stat(filename);
|
||||||
|
await this.storeInternalFileToDatabase({ path: filename, ...stat });
|
||||||
|
await this.extractInternalFileFromDatabase(filename);
|
||||||
|
await this.localDatabase.localDatabase.remove(id, revB);
|
||||||
|
return this.resolveConflictOnInternalFile(id);
|
||||||
|
} else {
|
||||||
|
Logger(`Object merge is not applicable.`, LOG_LEVEL.VERBOSE);
|
||||||
}
|
}
|
||||||
await this.app.vault.adapter.write(filename, result);
|
|
||||||
const stat = await this.app.vault.adapter.stat(filename);
|
|
||||||
await this.storeInternalFileToDatabase({ path: filename, ...stat });
|
|
||||||
await this.extractInternalFileFromDatabase(filename);
|
|
||||||
await this.localDatabase.localDatabase.remove(id, revB);
|
|
||||||
return this.resolveConflictOnInternalFile(id);
|
|
||||||
} else {
|
|
||||||
Logger(`Object merge is not applicable.`, LOG_LEVEL.VERBOSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const revBDoc = await this.localDatabase.localDatabase.get(id, { rev: revB });
|
const revBDoc = await this.localDatabase.localDatabase.get(id, { rev: revB });
|
||||||
// determine which revision should been deleted.
|
// determine which revision should been deleted.
|
||||||
// simply check modified time
|
// simply check modified time
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@
|
|||||||
.CodeMirror-wrap::before,
|
.CodeMirror-wrap::before,
|
||||||
.cm-s-obsidian>.cm-editor::before,
|
.cm-s-obsidian>.cm-editor::before,
|
||||||
.canvas-wrapper::before {
|
.canvas-wrapper::before {
|
||||||
content: var(--slsmessage);
|
content: attr(data-log);
|
||||||
text-align: right;
|
text-align: right;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
Reference in New Issue
Block a user