mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2025-12-24 07:01:29 +00:00
- Improved - New configuration to avoid exceeding throttle capacity. - The conflicted `data.json` is no longer merged automatically.
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { App, Modal } from "obsidian";
|
|
import { LoadedEntry } from "./lib/src/types";
|
|
import JsonResolvePane from "./JsonResolvePane.svelte";
|
|
|
|
export class JsonResolveModal extends Modal {
|
|
// result: Array<[number, string]>;
|
|
filename: string;
|
|
callback: (keepRev: string, mergedStr?: string) => Promise<void>;
|
|
docs: LoadedEntry[];
|
|
component: JsonResolvePane;
|
|
|
|
constructor(app: App, filename: string, docs: LoadedEntry[], callback: (keepRev: string, mergedStr?: string) => Promise<void>) {
|
|
super(app);
|
|
this.callback = callback;
|
|
this.filename = filename;
|
|
this.docs = docs;
|
|
}
|
|
async UICallback(keepRev: string, mergedStr?: string) {
|
|
this.close();
|
|
await this.callback(keepRev, mergedStr);
|
|
this.callback = null;
|
|
}
|
|
|
|
onOpen() {
|
|
const { contentEl } = this;
|
|
|
|
contentEl.empty();
|
|
|
|
if (this.component == null) {
|
|
this.component = new JsonResolvePane({
|
|
target: contentEl,
|
|
props: {
|
|
docs: this.docs,
|
|
callback: (keepRev, mergedStr) => this.UICallback(keepRev, mergedStr),
|
|
},
|
|
});
|
|
}
|
|
return;
|
|
}
|
|
|
|
|
|
onClose() {
|
|
const { contentEl } = this;
|
|
contentEl.empty();
|
|
// contentEl.empty();
|
|
if (this.callback != null) {
|
|
this.callback(null);
|
|
}
|
|
if (this.component != null) {
|
|
this.component.$destroy();
|
|
this.component = null;
|
|
}
|
|
}
|
|
}
|