@netless/window-manager 1.0.7-beta.8 → 1.0.7-beta.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.7-beta.8",
3
+ "version": "1.0.7-beta.9",
4
4
  "description": "Multi-window mode for Netless Whiteboard",
5
5
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
6
6
  "license": "MIT",
package/src/AppManager.ts CHANGED
@@ -72,7 +72,9 @@ export class AppManager {
72
72
  private callbacksNode: ScenesCallbacksNode | null = null;
73
73
  private appCreateQueue = new AppCreateQueue();
74
74
 
75
- private _focusAppCreatedResolve?: (appProxy: AppProxy) => void;
75
+ private _focusAppCreatedResolve?: (appProxy?: AppProxy) => void;
76
+ private _focusAppId: string | undefined;
77
+ private _resolveTimer: number | undefined;
76
78
 
77
79
  private sideEffectManager = new SideEffectManager();
78
80
 
@@ -342,9 +344,16 @@ export class AppManager {
342
344
 
343
345
  private async onCreated() {
344
346
  if (Object.keys(this.attributes.apps).length && this.store.focus) {
345
- await new Promise<AppProxy>(resolve => {
347
+ this._focusAppId = this.store.focus;
348
+ console.log("onCreated===>", this._focusAppId);
349
+ await new Promise<AppProxy | undefined>(resolve => {
346
350
  this._focusAppCreatedResolve = resolve;
351
+ this._resolveTimer = setTimeout(() => {
352
+ console.log("onCreated===>3333", this._focusAppId);
353
+ resolve(this.appProxies.get(this._focusAppId || ''));
354
+ }, 500);
347
355
  }).then(() => {
356
+ console.log("onCreated===>2222", this._focusAppId);
348
357
  this.focusByAttributes(this.attributes.apps);
349
358
  });
350
359
  }
@@ -595,7 +604,7 @@ export class AppManager {
595
604
  if (!appAttributes) {
596
605
  throw new Error("appAttributes is undefined");
597
606
  }
598
-
607
+
599
608
  this.appCreateQueue.push<AppProxy>(async () => {
600
609
  this.appStatus.set(id, AppStatus.StartCreate);
601
610
  const appProxy = await this.baseInsertApp(
@@ -612,9 +621,13 @@ export class AppManager {
612
621
  );
613
622
  if (
614
623
  appProxy &&
615
- this.store.focus === id &&
624
+ this._focusAppId === id &&
616
625
  this._focusAppCreatedResolve
617
626
  ) {
627
+ console.log("onCreated===>4444", this._focusAppId);
628
+ if (this._resolveTimer) {
629
+ clearTimeout(this._resolveTimer);
630
+ }
618
631
  this._focusAppCreatedResolve(appProxy);
619
632
  }
620
633
  return appProxy;
@@ -941,6 +954,10 @@ export class AppManager {
941
954
  this.sideEffectManager.flushAll();
942
955
  this._prevFocused = undefined;
943
956
  this._prevSceneIndex = undefined;
957
+ if (this._resolveTimer) {
958
+ clearTimeout(this._resolveTimer);
959
+ }
944
960
  this._focusAppCreatedResolve = undefined;
961
+ this._resolveTimer = undefined;
945
962
  }
946
963
  }
@@ -57,7 +57,6 @@ export function getExtendClass<T extends ExtendClassAble>(
57
57
  default:
58
58
  return baseClass;
59
59
  }
60
- } else {
61
- return baseClass;
62
60
  }
61
+ return baseClass;
63
62
  }