Skip to content

Commit

Permalink
fix(formula): touch dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushusir committed Nov 9, 2024
1 parent 7dc8f55 commit 501c7f0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
26 changes: 16 additions & 10 deletions packages/engine-formula/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import type { Dependency } from '@univerjs/core';
import type { IUniverEngineFormulaConfig } from './controller/config.schema';
import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core';
import { IConfigService, Inject, Injector, Plugin, touchDependencies } from '@univerjs/core';
import { CalculateController } from './controller/calculate.controller';
import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controller/config.schema';
import { FormulaController } from './controller/formula.controller';
Expand Down Expand Up @@ -78,22 +78,28 @@ export class UniverFormulaEnginePlugin extends Plugin {
}

override onReady(): void {
this._injector.get(FormulaController);
this._injector.get(SetDefinedNameController);
this._injector.get(SetSuperTableController);
touchDependencies(this._injector, [
[FormulaController],
[SetDefinedNameController],
[SetSuperTableController],
]);

if (!this._config?.notExecuteFormula) {
this._injector.get(SetOtherFormulaController);
this._injector.get(SetFeatureCalculationController);
this._injector.get(SetDependencyController);
this._injector.get(CalculateController);
touchDependencies(this._injector, [
[SetOtherFormulaController],
[SetFeatureCalculationController],
[SetDependencyController],
[CalculateController],
]);
}
}

override onRendered(): void {
if (!this._config?.notExecuteFormula) {
this._injector.get(ICalculateFormulaService);
this._injector.get(IFormulaDependencyGenerator);
touchDependencies(this._injector, [
[ICalculateFormulaService],
[IFormulaDependencyGenerator],
]);
}
}

Expand Down
10 changes: 6 additions & 4 deletions packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import type { Dependency } from '@univerjs/core';
import type { IUniverSheetsFormulaBaseConfig } from './controllers/config.schema';
import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
import { DependentOn, IConfigService, Inject, Injector, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { IRenderManagerService } from '@univerjs/engine-render';
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
Expand Down Expand Up @@ -86,9 +86,11 @@ export class UniverSheetsFormulaUIPlugin extends Plugin {
this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, dep));
});

this._injector.get(FormulaUIController); // FormulaProgressBar relies on TriggerCalculationController, but it is necessary to ensure that the formula calculation is done after rendered.
this._injector.get(FormulaClipboardController);
this._injector.get(FormulaRenderManagerController);
touchDependencies(this._injector, [
[FormulaUIController], // FormulaProgressBar relies on TriggerCalculationController, but it is necessary to ensure that the formula calculation is done after rendered.
[FormulaClipboardController],
[FormulaRenderManagerController],
]);

const componentManager = this._injector.get(ComponentManager);

Expand Down
19 changes: 12 additions & 7 deletions packages/sheets-formula/src/sheets-formula.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
IUniverSheetsFormulaBaseConfig,
IUniverSheetsFormulaRemoteConfig,
} from './controllers/config.schema';
import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
import { DependentOn, IConfigService, Inject, Injector, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';

import { fromModule, IRPCChannelService, toModule } from '@univerjs/rpc';
Expand Down Expand Up @@ -117,14 +117,19 @@ export class UniverSheetsFormulaPlugin extends Plugin {
}

override onReady(): void {
this._injector.get(FormulaController);
this._injector.get(ActiveDirtyController);
this._injector.get(ArrayFormulaCellInterceptorController);
this._injector.get(UpdateFormulaController);
this._injector.get(UpdateDefinedNameController);
touchDependencies(this._injector, [
[FormulaController],
[ActiveDirtyController],
[ArrayFormulaCellInterceptorController],
[UpdateFormulaController],
[UpdateDefinedNameController],
[TriggerCalculationController],
]);
}

override onRendered(): void {
this._injector.get(DefinedNameController);
touchDependencies(this._injector, [
[DefinedNameController],
]);
}
}

0 comments on commit 501c7f0

Please sign in to comment.