Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incremental loading for actions #449

Merged
merged 8 commits into from
Aug 26, 2020
13 changes: 7 additions & 6 deletions app/assets/javascripts/directives/views/actionsMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ActionsMenuCtrl extends PureViewCtrl implements ActionsMenuScope {

application!: WebApplication
item!: SNItem
public loadingExtensions: boolean = true
loadingExtensions: boolean = true
johnny243 marked this conversation as resolved.
Show resolved Hide resolved

/* @ngInject */
constructor(
Expand All @@ -56,16 +56,17 @@ class ActionsMenuCtrl extends PureViewCtrl implements ActionsMenuScope {
const actionExtensions = this.application.actionsManager!.getExtensions().sort((a, b) => {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
});
const extensionsForItem = await Promise.all(actionExtensions.map((extension) => {
return this.application.actionsManager!.loadExtensionInContextOfItem(
await Promise.all(actionExtensions.map(async (extension) => {
const extensionsForItem = await this.application.actionsManager!.loadExtensionInContextOfItem(
extension,
this.props.item
);
const extensions = this.state.extensions || [];
this.setState({
extensions: extensions.concat(extensionsForItem)
});
}));
this.loadingExtensions = false;
johnny243 marked this conversation as resolved.
Show resolved Hide resolved
await this.setState({
extensions: extensionsForItem
});
}

async executeAction(action: Action, extension: SNActionsExtension) {
Expand Down