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

Commit 9dcb741

Browse files
committed
a delay is needed between write inputs of the queue
1 parent eb37ca8 commit 9dcb741

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/services/EditEngineService.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,31 @@ class EditEngine {
7979
* @param newColumnValue
8080
* @param option
8181
*/
82-
public async updateRowFileProxy(file: TFile, columnId: string, newValue: Literal, columns: TableColumn[], ddbbConfig: LocalSettings, option: string): Promise<void> {
83-
this.onFlyEditions.push({ file, columnId, newValue, columns, ddbbConfig, option });
84-
clearTimeout(this.currentTimeout);
82+
public async updateRowFileProxy(p_file: TFile, p_columnId: string, p_newValue: Literal, p_columns: TableColumn[], p_ddbbConfig: LocalSettings, p_option: string): Promise<void> {
83+
await this.onFlyEditions.push({
84+
file: p_file,
85+
columnId: p_columnId,
86+
newValue: p_newValue,
87+
columns: p_columns,
88+
ddbbConfig: p_ddbbConfig,
89+
option: p_option
90+
});
91+
if (this.currentTimeout) {
92+
clearTimeout(this.currentTimeout);
93+
}
8594
this.currentTimeout = setTimeout(async () => {
8695
// Call all onFlyEditions
8796
while (this.onFlyEditions.length > 0) {
88-
const { file, columnId, newValue, columns, ddbbConfig, option } = this.onFlyEditions.pop();
97+
98+
const { file, columnId, newValue, columns, ddbbConfig, option } = this.onFlyEditions.shift();
8999
await this.updateRowFile(file, columnId, newValue, columns, ddbbConfig, option)
90100
.catch((err) => {
91101
showDBError(EditionError.YamlRead, err);
92102
});
93-
this.currentTimeout = null;
103+
// Delay to avoid overloading the system
104+
await new Promise((resolve) => setTimeout(resolve, 25));
94105
}
106+
this.currentTimeout = null;
95107
}, 250);
96108
}
97109

0 commit comments

Comments
 (0)