Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 50c0a7d

Browse files
committed
Merge branch '616-bug-multiple-persistent-formula-values-are-not-saved-on-refresh-only-one-of-the-persistent-values-is-updated-in-the-yaml-frontmatter'
2 parents 8293aa3 + d6fd174 commit 50c0a7d

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

src/cdm/ServicesModel.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { TFile } from "obsidian"
2+
import { TableColumn } from "cdm/FolderModel"
3+
import { LocalSettings } from "cdm/SettingsModel"
4+
import { Literal } from "obsidian-dataview"
5+
6+
export type EditArguments = {
7+
file: TFile,
8+
columnId: string,
9+
newValue: Literal,
10+
columns: TableColumn[],
11+
ddbbConfig: LocalSettings,
12+
option: string
13+
}

src/services/EditEngineService.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ import { inlineRegexInFunctionOf } from "helpers/QueryHelper";
1212
import { EditionError, showDBError } from "errors/ErrorTypes";
1313
import { hasFrontmatter } from "helpers/VaultManagement";
1414
import obtainRowDatabaseFields from "parsers/FileToRowDatabaseFields";
15+
import { EditArguments } from "cdm/ServicesModel";
16+
1517
class EditEngine {
1618
private static instance: EditEngine;
1719

20+
private onFlyEditions: EditArguments[] = [];
21+
private currentTimeout: NodeJS.Timeout = null;
1822
/**
1923
* Modify all the files asociated to the rows using lambaUpdate per every row filtered by the lambdaFilter
2024
* @param lambdaUpdate
@@ -76,11 +80,19 @@ class EditEngine {
7680
* @param option
7781
*/
7882
public async updateRowFileProxy(file: TFile, columnId: string, newValue: Literal, columns: TableColumn[], ddbbConfig: LocalSettings, option: string): Promise<void> {
79-
queueMicrotask(async () => {
80-
await this.updateRowFile(file, columnId, newValue, columns, ddbbConfig, option).catch((err) => {
81-
showDBError(EditionError.YamlRead, err);
82-
});
83-
});
83+
this.onFlyEditions.push({ file, columnId, newValue, columns, ddbbConfig, option });
84+
if (this.currentTimeout) {
85+
clearTimeout(this.currentTimeout);
86+
}
87+
this.currentTimeout = setTimeout(async () => {
88+
// Call all onFlyEditions
89+
while (this.onFlyEditions.length > 0) {
90+
const { file, columnId, newValue, columns, ddbbConfig, option } = this.onFlyEditions.pop();
91+
await this.updateRowFile(file, columnId, newValue, columns, ddbbConfig, option).catch((err) => {
92+
showDBError(EditionError.YamlRead, err);
93+
});
94+
}
95+
}, 250);
8496
}
8597

8698
private async updateRowFile(file: TFile, columnId: string, newValue: Literal, columns: TableColumn[], ddbbConfig: LocalSettings, option: string): Promise<void> {

0 commit comments

Comments
 (0)