mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 21:31:59 +03:00
Merge 525c119118 into 37cfd2144b
This commit is contained in:
commit
2fdb54f35a
1 changed files with 21 additions and 4 deletions
25
src/main.ts
25
src/main.ts
|
|
@ -940,14 +940,16 @@ async function initSettings(): Promise<void> {
|
||||||
await runBackups(settings.dataDir, settings.deletedRetentionDays);
|
await runBackups(settings.dataDir, settings.deletedRetentionDays);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initDataAndEngine(): Promise<void> {
|
function initEngine(): void {
|
||||||
engine = new SumEngine({
|
engine = new SumEngine({
|
||||||
precision: settings.precision,
|
precision: settings.precision,
|
||||||
groupSeparator: settings.groupSeparator,
|
groupSeparator: settings.groupSeparator,
|
||||||
decimalSeparator: settings.decimalSeparator,
|
decimalSeparator: settings.decimalSeparator,
|
||||||
dateFormat: settings.dateFormat,
|
dateFormat: settings.dateFormat,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initData(): Promise<void> {
|
||||||
const stored = await loadAppData(settings.dataDir);
|
const stored = await loadAppData(settings.dataDir);
|
||||||
// a corrupt or foreign documents.json must not crash the boot
|
// a corrupt or foreign documents.json must not crash the boot
|
||||||
if (
|
if (
|
||||||
|
|
@ -968,10 +970,9 @@ async function initDataAndEngine(): Promise<void> {
|
||||||
}
|
}
|
||||||
if (!data.docs.some((d) => d.id === data.activeId))
|
if (!data.docs.some((d) => d.id === data.activeId))
|
||||||
data.activeId = data.docs[0].id;
|
data.activeId = data.docs[0].id;
|
||||||
|
}
|
||||||
|
|
||||||
const scripts = await loadExtensionScripts();
|
function initWorkspace(): void {
|
||||||
await runExtensions(engine, scripts);
|
|
||||||
|
|
||||||
workspace = new Workspace(engine, () =>
|
workspace = new Workspace(engine, () =>
|
||||||
data.docs.map((d) => ({
|
data.docs.map((d) => ({
|
||||||
id: d.id,
|
id: d.id,
|
||||||
|
|
@ -979,7 +980,9 @@ async function initDataAndEngine(): Promise<void> {
|
||||||
text: data.contents[d.id] ?? "",
|
text: data.contents[d.id] ?? "",
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initEditor(): void {
|
||||||
editor = new SumEditor(
|
editor = new SumEditor(
|
||||||
$("#editor"),
|
$("#editor"),
|
||||||
$("#results"),
|
$("#results"),
|
||||||
|
|
@ -1016,7 +1019,9 @@ async function initDataAndEngine(): Promise<void> {
|
||||||
// the editor above was seeded directly with initialText (not via switchDoc),
|
// the editor above was seeded directly with initialText (not via switchDoc),
|
||||||
// so a reopened sheet with "on 2024-01-01" needs its own historical-rate fetch
|
// so a reopened sheet with "on 2024-01-01" needs its own historical-rate fetch
|
||||||
void fetchNeededHistoricalRates(data.contents[data.activeId] ?? "");
|
void fetchNeededHistoricalRates(data.contents[data.activeId] ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function initSearchUI(): void {
|
||||||
search = initSearch({
|
search = initSearch({
|
||||||
engine,
|
engine,
|
||||||
workspace,
|
workspace,
|
||||||
|
|
@ -1034,6 +1039,18 @@ async function initDataAndEngine(): Promise<void> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function initDataAndEngine(): Promise<void> {
|
||||||
|
initEngine();
|
||||||
|
await initData();
|
||||||
|
|
||||||
|
const scripts = await loadExtensionScripts();
|
||||||
|
await runExtensions(engine, scripts);
|
||||||
|
|
||||||
|
initWorkspace();
|
||||||
|
initEditor();
|
||||||
|
initSearchUI();
|
||||||
|
}
|
||||||
|
|
||||||
function bindTitleUI(): void {
|
function bindTitleUI(): void {
|
||||||
const titleField = $<HTMLInputElement>("#doc-title");
|
const titleField = $<HTMLInputElement>("#doc-title");
|
||||||
titleField.addEventListener("change", () => {
|
titleField.addEventListener("change", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue