mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-01-10 15:29:16 +00:00
- Task scheduling logics has been rewritten. - Possibly many bugs and fragile behaviour has been fixed - Fixed: - Remote-chunk-fetching now works with keeping request intervals - New feature: - We can show only the icons in the editor.
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { App, Modal } from "./deps";
|
|
import type { ReactiveInstance, } from "./lib/src/reactive";
|
|
import { logMessages } from "./lib/src/stores";
|
|
import { escapeStringToHTML } from "./lib/src/strbin";
|
|
import ObsidianLiveSyncPlugin from "./main";
|
|
|
|
export class LogDisplayModal extends Modal {
|
|
plugin: ObsidianLiveSyncPlugin;
|
|
logEl: HTMLDivElement;
|
|
unsubscribe: () => void;
|
|
constructor(app: App, plugin: ObsidianLiveSyncPlugin) {
|
|
super(app);
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
onOpen() {
|
|
const { contentEl } = this;
|
|
this.titleEl.setText("Sync status");
|
|
|
|
contentEl.empty();
|
|
const div = contentEl.createDiv("");
|
|
div.addClass("op-scrollable");
|
|
div.addClass("op-pre");
|
|
this.logEl = div;
|
|
function updateLog(logs: ReactiveInstance<string[]>) {
|
|
const e = logs.value;
|
|
let msg = "";
|
|
for (const v of e) {
|
|
msg += escapeStringToHTML(v) + "<br>";
|
|
}
|
|
this.logEl.innerHTML = msg;
|
|
}
|
|
logMessages.onChanged(updateLog);
|
|
this.unsubscribe = () => logMessages.offChanged(updateLog);
|
|
}
|
|
onClose() {
|
|
const { contentEl } = this;
|
|
contentEl.empty();
|
|
if (this.unsubscribe) this.unsubscribe();
|
|
}
|
|
}
|