@interopio/workspaces-api 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.md CHANGED
@@ -1,3 +1,5 @@
1
+ 4.0.2
2
+ fix: Optimized the closing of a workspace
1
3
  4.0.0
2
4
  feat: io.Connect Browser 4.0
3
5
  3.5.7
@@ -2775,10 +2775,9 @@ class Workspace {
2775
2775
  }
2776
2776
  async close() {
2777
2777
  const controller = getData$3(this).controller;
2778
- const workspaces = await getData$3(this).frame.workspaces();
2778
+ const isLastWorkspaceInFrame = await controller.isLastWorkspaceInFrame(this.id, this.frameId);
2779
2779
  const platformFrameId = (await controller.getPlatformFrameId()).id;
2780
- const shouldCloseFrame = workspaces.length === 1 &&
2781
- workspaces.every((wsp) => wsp.id === this.id) &&
2780
+ const shouldCloseFrame = isLastWorkspaceInFrame &&
2782
2781
  platformFrameId !== this.frame.id;
2783
2782
  if (shouldCloseFrame) {
2784
2783
  return this.frame.close();
@@ -4597,6 +4596,11 @@ class MainController {
4597
4596
  }));
4598
4597
  return workspacesForFrame;
4599
4598
  }
4599
+ async isLastWorkspaceInFrame(workspaceId, frameId) {
4600
+ const workspaceSummaries = await this.getAllWorkspaceSummaries();
4601
+ const summariesForFrame = workspaceSummaries.filter((s) => s.frameId === frameId);
4602
+ return summariesForFrame.length === 1 && summariesForFrame[0].id === workspaceId;
4603
+ }
4600
4604
  async getAllWorkspaceSummaries() {
4601
4605
  const allSummariesResult = await this.bridge.send(OPERATIONS.getAllWorkspacesSummaries.name, {});
4602
4606
  return this.base.getAllWorkspaceSummaries(allSummariesResult);
@@ -5104,7 +5108,7 @@ class IoC {
5104
5108
  }
5105
5109
  }
5106
5110
 
5107
- var version = "4.0.1";
5111
+ var version = "4.0.2";
5108
5112
 
5109
5113
  const composeAPI = (glue, ioc) => {
5110
5114
  const controller = ioc.controller;