You've already forked obsidian-livesync
mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2025-07-16 00:14:19 +02:00
- fix for the pop-out window.
- fix file handling in boot sequence.
This commit is contained in:
24
src/main.ts
24
src/main.ts
@ -1388,10 +1388,10 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
this.statusBar.setText(newMsg.split("\n")[0]);
|
this.statusBar.setText(newMsg.split("\n")[0]);
|
||||||
|
|
||||||
if (this.settings.showStatusOnEditor) {
|
if (this.settings.showStatusOnEditor) {
|
||||||
const root = document.documentElement;
|
const root = activeDocument.documentElement;
|
||||||
root.style.setProperty("--slsmessage", '"' + (newMsg + "\n" + newLog).split("\n").join("\\a ") + '"');
|
root.style.setProperty("--slsmessage", '"' + (newMsg + "\n" + newLog).split("\n").join("\\a ") + '"');
|
||||||
} else {
|
} else {
|
||||||
const root = document.documentElement;
|
const root = activeDocument.documentElement;
|
||||||
root.style.setProperty("--slsmessage", '""');
|
root.style.setProperty("--slsmessage", '""');
|
||||||
}
|
}
|
||||||
if (this.logHideTimer != null) {
|
if (this.logHideTimer != null) {
|
||||||
@ -1528,10 +1528,10 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
do {
|
do {
|
||||||
const syncFilesX = syncFiles.splice(0, 100);
|
const syncFilesX = syncFiles.splice(0, 100);
|
||||||
const docs = await this.localDatabase.localDatabase.allDocs({ keys: syncFilesX.map(e => path2id(e.path)), include_docs: true })
|
const docs = await this.localDatabase.localDatabase.allDocs({ keys: syncFilesX.map(e => path2id(e.path)), include_docs: true })
|
||||||
const syncFilesToSync = syncFilesX.map((e) => ({ ...e, doc: docs.rows.find(ee => ee.id == path2id(e.path)).doc as LoadedEntry }));
|
const syncFilesToSync = syncFilesX.map((e) => ({ file: e, doc: docs.rows.find(ee => ee.id == path2id(e.path)).doc as LoadedEntry }));
|
||||||
|
|
||||||
await runAll(`CHECK FILE STATUS:${syncFiles.length}/${docsCount}`, syncFilesToSync, async (e) => {
|
await runAll(`CHECK FILE STATUS:${syncFiles.length}/${docsCount}`, syncFilesToSync, async (e) => {
|
||||||
caches = await this.syncFileBetweenDBandStorage(e, initialScan, caches);
|
caches = await this.syncFileBetweenDBandStorage(e.file, e.doc, initialScan, caches);
|
||||||
});
|
});
|
||||||
} while (syncFiles.length > 0);
|
} while (syncFiles.length > 0);
|
||||||
await this.localDatabase.kvDB.set("diff-caches", caches);
|
await this.localDatabase.kvDB.set("diff-caches", caches);
|
||||||
@ -1806,9 +1806,19 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
//when to opened file;
|
//when to opened file;
|
||||||
}
|
}
|
||||||
|
|
||||||
async syncFileBetweenDBandStorage(file: TFile & { doc?: LoadedEntry }, initialScan: boolean, caches: { [key: string]: { storageMtime: number; docMtime: number } }) {
|
async syncFileBetweenDBandStorage(file: TFile, doc: LoadedEntry, initialScan: boolean, caches: { [key: string]: { storageMtime: number; docMtime: number } }) {
|
||||||
const doc = file.doc;
|
if (!doc) {
|
||||||
if (!doc) return;
|
throw new Error(`Missing doc:${(file as any).path}`)
|
||||||
|
}
|
||||||
|
if (!(file instanceof TFile) && "path" in file) {
|
||||||
|
const w = this.app.vault.getAbstractFileByPath((file as any).path);
|
||||||
|
if (w instanceof TFile) {
|
||||||
|
file = w;
|
||||||
|
} else {
|
||||||
|
throw new Error(`Missing file:${(file as any).path}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const storageMtime = ~~(file.stat.mtime / 1000);
|
const storageMtime = ~~(file.stat.mtime / 1000);
|
||||||
const docMtime = ~~(doc.mtime / 1000);
|
const docMtime = ~~(doc.mtime / 1000);
|
||||||
const dK = `${file.path}-diff`;
|
const dK = `${file.path}-diff`;
|
||||||
|
Reference in New Issue
Block a user