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

[MWPW-159324] Progress loader circle delay handling #150

Open
wants to merge 1 commit into
base: stage
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions unitylibs/core/workflow/workflow-photoshop/action-binder.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ export default class ActionBinder {
this.errorToastEl = null;
this.psApiConfig = this.getPsApiConfig();
this.serviceHandler = null;
this.loadServiceHandler();
this.loadSVGsMaybe();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will add both progress circle and all the svgs (Including the ones that are present on the buttons that will be made visible only when user interacts) in the critical rendering path. Can we split this into two functions and call the progress circle js and css loader here and load svg in psActions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something, but this will not work because we'll still load the other SVGs when the user clicks on "Remove background".
This will still cause a delay between the button click and the 'show' action for the progress circle.

}

async loadServiceHandler() {
const { default: ServiceHandler } = await import(`${getUnityLibs()}/core/workflow/${this.workflowCfg.name}/service-handler.js`);
this.serviceHandler = new ServiceHandler(
this.workflowCfg.targetCfg.renderWidget,
this.canvasArea,
);
}

async loadSVGsMaybe() {
if (this.workflowCfg.targetCfg.renderWidget) {
await loadSvgs(this.canvasArea.querySelectorAll('.unity-widget img[src*=".svg"'));
if (!this.progressCircleEl) {
this.progressCircleEl = await this.createSpectrumProgress();
this.canvasArea.append(this.progressCircleEl);
}
}
}

getPsApiConfig() {
Expand Down Expand Up @@ -62,19 +82,6 @@ export default class ActionBinder {
}

async psActionMaps(values, e) {
const { default: ServiceHandler } = await import(`${getUnityLibs()}/core/workflow/${this.workflowCfg.name}/service-handler.js`);
this.serviceHandler = new ServiceHandler(
this.workflowCfg.targetCfg.renderWidget,
this.canvasArea,
);
if (this.workflowCfg.targetCfg.renderWidget) {
const svgs = this.canvasArea.querySelectorAll('.unity-widget img[src*=".svg"');
await loadSvgs(svgs);
if (!this.progressCircleEl) {
this.progressCircleEl = await this.createSpectrumProgress();
this.canvasArea.append(this.progressCircleEl);
}
}
for (const value of values) {
switch (true) {
case value.actionType == 'hide':
Expand Down