@@ -12,9 +12,13 @@ import { inlineRegexInFunctionOf } from "helpers/QueryHelper";
1212import { EditionError , showDBError } from "errors/ErrorTypes" ;
1313import { hasFrontmatter } from "helpers/VaultManagement" ;
1414import obtainRowDatabaseFields from "parsers/FileToRowDatabaseFields" ;
15+ import { EditArguments } from "cdm/ServicesModel" ;
16+
1517class 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